Imports MindFusion.Diagramming
Imports MindFusion.Drawing
Imports DevExpress.XtraBars.Docking
Imports DevExpress.XtraEditors

Public Class UcnDiagramCanvasBase
    'represents MindFusion.Diagramming.WinForms.DiagramView & MindFusion.Diagramming.Diagram for drawing

#Region "Attributes"
#Region "Private attributes"
    '------------------------------------------------------------------------------------------------------------------------
    'USED ON kkMainTab TAB
    Private WithEvents MoDSaModSolutionFile As ClsDSaModSolutionFile  'aMod solution file with paths to all aMod files
    Private MoOpenedAmodFiles As ClsMMCollection 'collection of opened aMod files
    Private MoUcnComboboxJoinedModule As UcnCombobox = Nothing 'combobox with list of modules in aMod solution

    'USED ON kkClassDiagramTab TAB
    Private WithEvents MoDSaModFile As ClsDSaModFile = Nothing 'aMod file - "parent" for version
    Private WithEvents MoAmodVersion As ClsDsAModOneVersion = Nothing 'aMod version

    'USED ON kkVersionComparisonTab TAB
    Private WithEvents MoLeftCanvasBase As UcnDiagramCanvasBase = Nothing 'left canvas in version comparison
    Private WithEvents MoRightCanvasBase As UcnDiagramCanvasBase = Nothing 'right canvas in version comparison
    Private WithEvents MoDSversionCompare As ClsDSversionCompare = Nothing 'dataset with version changes after comparison of two versions
    '------------------------------------------------------------------------------------------------------------------------
    Private MoUcnDiagramCanvasAdvanced As UcnDiagramCanvasAdvanced = Nothing 'UcnDiagramCanvasAdvanced usercontrol in tab
    Private MeSideOfCanvas As GeSideOfCanvas = GeSideOfCanvas.kkNone ''side of canvas in comparison tab ("left" or "right"), otherwise "none"
    Private MbReadyForUse As Boolean = False 'indicates proper initialization of usercontrol
    Private WithEvents MoHand As ClsHand 'represents mouse action - what is user performing by mouse
    Private MoLastHoveredItem As DiagramItem = Nothing 'I need to draw shape for creating link from node only when mouse is hovered above node. After another node is hovered, I need to hide that shape for creating link
    Private WithEvents MoDiagramLayout As ClsDiagramLayout = New ClsDiagramLayout 'represents object for diagram layouting with various types of layouts
    Private MoTabControl As UcnTabControl 'UcnTabControl which are tabs in
    Private MoTabPage As ClsUcnTabPage 'ClsTabPage which is UcnDiagramCanvasBase in
    Private MoMainTabPage As ClsUcnTabPage 'Main ClsTabPage representing main tab which is this module from
    'docking panels
    Private WithEvents MoDockPanelActions As DockPanel
    Private WithEvents MoDockPanelNotes As DockPanel
    Private WithEvents MoDockPanelProperties As DockPanel
    Private WithEvents MoDockPanelOverview As DockPanel
    Private WithEvents MoDockPanelJoinedModulesInfo As DockPanel
    Private WithEvents MoDockPanelItemChanges As DockPanel
    Private WithEvents MoDockPanelVersionsChanges As DockPanel
    Private WithEvents MoDockManager As DockManager
    'usercontrols
    Private WithEvents MoUcnPropertiesOfItemUC As UcnGridUnbound
    Private WithEvents MoUcnPropertiesOfTableRowsUC As UcnGridCard
    Private WithEvents MoUcnRTFeditorUC As UcnRTFeditor
    Private WithEvents MoUcnRelationsUC As UcnListBox
    Private WithEvents MoUcnJoinedModulesInfoUC As UcnGridUnbound
    Private WithEvents MoUcnVersionsChangesUC As UcnGridUnbound
    Private WithEvents MoItemChangesMemoEdit As DevExpress.XtraEditors.MemoEdit
#End Region
#End Region
#Region "Constructors & Init"
    Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.


        '**********************************************************************
        InitControl()
        Init()
        '**********************************************************************
    End Sub
    'setting usercontrol settings after it is created
    Private Function InitControl() As GeActionResult
        SetReadyForUse(False) 'disabling usercontrol
        Try
            xtrRibbonControl.TransparentEditors = True 'VERY IMPORTANT!!!

            'manually seting images to menu - coz they are 16x16 sized and image list assigned to ribbon is 48x48 sized
            barBtnAnnealLayout.Glyph = imlMenu16x16.Images("ANNEALLAYOUT")
            barBtnCircularLayout.Glyph = imlMenu16x16.Images("CIRCULARLAYOUT")
            barBtnFlowchartLayout.Glyph = imlMenu16x16.Images("FLOWCHARTLAYOUT")
            barBtnFlowLayout.Glyph = imlMenu16x16.Images("FLOWLAYOUT")
            barBtnGridLayout.Glyph = imlMenu16x16.Images("GRIDLAYOUT")
            barBtnLayeredLayout.Glyph = imlMenu16x16.Images("LAYEREDLAYOUT")
            barBtnOrthogonalLayout.Glyph = imlMenu16x16.Images("ORTHOGONALLAYOUT")
            barBtnOrthogonalRouter.Glyph = imlMenu16x16.Images("ORTHOGONALROUTER")
            barBtnSpringLayout.Glyph = imlMenu16x16.Images("SPRINGLAYOUT")
            barBtnTopologicalLayout.Glyph = imlMenu16x16.Images("TOPOLOGICALLAYOUT")
            barBtnTreeLayout.Glyph = imlMenu16x16.Images("TREELAYOUT")

            barCheckItemPanelActions.Glyph = imlMenu16x16.Images("ACTIONS")
            barCheckItemPanelProperties.Glyph = imlMenu16x16.Images("PROPERTIES")
            barCheckItemPanelOverview.Glyph = imlMenu16x16.Images("OVERVIEW")
            barCheckItemPanelNotes.Glyph = imlMenu16x16.Images("NOTES")

            'initializing diagram
            Me.fcDiagramView.CustomBehavior = New ClsCustomBehavior(Me.fcDiagramView)
            Me.fcDiagramView.ModificationStart = ModificationStart.AutoHandles
            Me.fcDiagram.HitTestPriority = HitTestPriority.ZOrder 'set ZOrder order because of possibility of editing links inside of container
            Me.fcDiagramView.ShowScrollbars = True 'whether scrollbars are present in the document's area
            Me.fcDiagramView.AutoScroll = True 'whether auto scrolling of the document area is enabled when new items are added or existing items are being dragged outside the visible area
            Me.fcDiagramView.ModifierKeyActions.Alt = ModifierKeyAction.Pan  'specify the function of the ALT key
            Me.fcDiagramView.ModifierKeyActions.Control = ModifierKeyAction.Select  'specify the function of the CTRL key
            Me.fcDiagramView.ModifierKeyActions.Shift = ModifierKeyAction.OverrideBehavior 'specify the function of the SHIFT key
            Me.fcDiagramView.DelKeyAction = DelKeyAction.None  'what action should be performed when the user hits the Del key
            Me.fcDiagramView.AllowDrop = True 'allowing drag&drop
            Me.fcDiagramView.Behavior = Behavior.Custom   'DrawLinks 'how the component responds to actions performed by the user
            Me.fcDiagramView.AllowInplaceEdit = False 'whether in-place editing of the text of objects is enabled
            Me.fcDiagramView.InplaceEditAcceptOnEnter = True 'whether pressing the ENTER key should exit inplace-edit mode and accept changes made to text
            Me.fcDiagramView.InplaceEditCancelOnEsc = True 'whether pressing the ESC key should exit inplace-edit mode and reject changes made to text
            Me.fcDiagram.SelectAfterCreate = False  'whether newly created objects are automatically selected
            Me.fcDiagram.ActiveItemHandlesColor = Color.Blue 'the color of the adjustment handles of the active item
            Me.fcDiagram.SelectedItemHandlesColor = Color.Gray 'the color of the manipulation handles of selected objects
            Me.fcDiagram.AutoResize = AutoResize.RightAndDown  'whether the document area must be resized automatically so it fits the diagram contents each time an item is created, deleted or moved, either by end-users or by calling of methods
            Me.fcDiagram.SelectionOnTop = True 'whether selected items should be painted on top of other items
            Me.fcDiagram.BackBrush = New SolidBrush(Color.Red) 'this will be changed later
            Me.fcDiagram.EnableStyledText = True 'the value is used to initialize the EnableStyledText property of new nodes
            Me.fcDiagram.ShowAnchors = ShowAnchors.Never 'when anchors points should be displayed
            Me.fcDiagram.SnapToAnchor = SnapToAnchor.OnCreateOrModify  'when link ends are snapped to nearest anchor points
            Me.fcDiagram.RoundedLinks = True 'rounded bends     
            'USED WHILE CREATING NEW ITEMS IN DIAGRAM AND IN DATASET!
            Me.fcDiagram.TableCaption = GsStringNullValue 'default text for tables' captions
            Me.fcDiagram.LinkText = GsStringNullValue 'default text of links
            Me.fcDiagram.ContainerCaption = GsStringNullValue 'default value for the Caption property of containers
            'USED WHILE CREATING NEW ITEMS IN DIAGRAM AND IN DATASET!

            'Me.fcDiagram.AllowUnanchoredLinks = False  'links can be connected to nodes to which there aren't anchor points assigned
            'Me.fcDiagram.RoutingOptions.TriggerRerouting = RerouteLinks.WhileCreating Or RerouteLinks.WhenModified 'in what circumstances links must be rerouted automatically

            SetDefaultNewSettingsOfCanvas()
            ReflectCanvasSettings()

            'initializing MoHand object
            MoHand = New ClsHand
            MoHand.PrimaryOperation = GePrimaryOperationOfHand.kkNeutral
            MoHand.SecondaryOperation = GeSecondaryOperationOfHand.kkIdle
            MoHand.TypeOfLink = KrosLib.Data.eRelationType.OneToMany 'kkRelationTypes.kk_1_n

            ''DOCASNE
            SetTemporarySettings()
            ''DOCASNE

            SetReadyForUse(True) 'enabling usercontrol
            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'initialization of controls
    Public Function Init() As GeActionResult
        Try
            Me.fcDiagramView.ZoomFactor = 100 'setting zoom factor
            ZoomCanvasFromZoom(Me.fcDiagramView.ZoomFactor)
            ReflectZoom()
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
#End Region
#Region "Properties"
#Region "Public properties"
    Public ReadOnly Property ReadyForUse() As Boolean
        Get
            Return MbReadyForUse
        End Get
    End Property
    Public ReadOnly Property SideOfCanvas() As GeSideOfCanvas
        Get
            Return MeSideOfCanvas
        End Get
    End Property
    Public ReadOnly Property DSaModSolutionFile() As ClsDSaModSolutionFile
        Get
            Return MoDSaModSolutionFile
        End Get
    End Property
    Public ReadOnly Property DSaModFile() As ClsDSaModFile
        Get
            Return MoDSaModFile
        End Get
    End Property
    Public ReadOnly Property OpenedAmodFiles() As ClsMMCollection
        Get
            Return MoOpenedAmodFiles
        End Get
    End Property
    Public ReadOnly Property AmodFilePath() As String
        Get
            Return MoDSaModFile.Path
        End Get
    End Property
    Public ReadOnly Property AmodVersion() As ClsDsAModOneVersion
        Get
            Return MoAmodVersion
        End Get
    End Property
    Public ReadOnly Property UcnComboboxJoinedModule() As UcnCombobox
        Get
            Return MoUcnComboboxJoinedModule
        End Get
    End Property
    Public ReadOnly Property IsThisTheLastVersion() As Boolean
        Get
            Return DSaModFile.Dat.GetLastVersion = AmodVersion.GetVersionVID
        End Get
    End Property
#End Region
#End Region
#Region "Events handler"
#Region "fcDiagramView - Events handler"
    Private Sub fcDiagramView_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles fcDiagramView.MouseMove
        If MoTabPage.TypeOfTab <> GeTypeOfTab.kkVersionComparisonTab Then
            If fcDiagram.Interaction Is Nothing Or (fcDiagram.Interaction IsNot Nothing AndAlso fcDiagram.Interaction.Action <> Action.Create AndAlso fcDiagram.Interaction.Action <> Action.Modify) Then
                'Dim LoActualHoveredItem As DiagramItem = fcDiagram.GetItemAt(fcDiagramView.ClientToDoc(e.Location), True)
                Dim LoActualHoveredItem As DiagramItem = fcDiagram.GetNodeAt(fcDiagramView.ClientToDoc(e.Location), 5)

                'hide arrow for new link
                If MoLastHoveredItem IsNot Nothing AndAlso Not MoLastHoveredItem.Equals(LoActualHoveredItem) AndAlso (MoLastHoveredItem.SubordinateGroup IsNot Nothing AndAlso Not MoLastHoveredItem.SubordinateGroup.AttachedNodes(0).Equals(LoActualHoveredItem)) Then
                    Select Case MoLastHoveredItem.GetType.Name
                        Case "ClsMMTableNode"
                            CType(MoLastHoveredItem, ClsMMTableNode).MMSetVisibilityOfNodeForNewLink(False)
                        Case "ClsMMModuleNode"
                            CType(MoLastHoveredItem, ClsMMModuleNode).MMSetVisibilityOfNodeForNewLink(False)
                        Case "ClsMMNoteNode"
                            CType(MoLastHoveredItem, ClsMMNoteNode).MMSetVisibilityOfNodeForNewLink(False)
                        Case "ClsMMActorNode"
                            CType(MoLastHoveredItem, ClsMMActorNode).MMSetVisibilityOfNodeForNewLink(False)
                        Case "ClsMMActivityNode"
                            CType(MoLastHoveredItem, ClsMMActivityNode).MMSetVisibilityOfNodeForNewLink(False)
                        Case "ClsMMNodeForNewLink"

                    End Select
                End If

                'show arrow for new link
                If LoActualHoveredItem IsNot Nothing AndAlso Not LoActualHoveredItem.Equals(MoLastHoveredItem) Then
                    Select Case LoActualHoveredItem.GetType.Name
                        Case "ClsMMTableNode"
                            CType(LoActualHoveredItem, ClsMMTableNode).MMSetVisibilityOfNodeForNewLink(True)
                        Case "ClsMMModuleNode"
                            CType(LoActualHoveredItem, ClsMMModuleNode).MMSetVisibilityOfNodeForNewLink(True)
                        Case "ClsMMNoteNode"
                            CType(LoActualHoveredItem, ClsMMNoteNode).MMSetVisibilityOfNodeForNewLink(True)
                        Case "ClsMMActorNode"
                            CType(LoActualHoveredItem, ClsMMActorNode).MMSetVisibilityOfNodeForNewLink(True)
                        Case "ClsMMActivityNode"
                            CType(LoActualHoveredItem, ClsMMActivityNode).MMSetVisibilityOfNodeForNewLink(True)
                        Case "ClsMMNodeForNewLink"
                    End Select
                End If

                If LoActualHoveredItem IsNot Nothing Then
                    If Not LoActualHoveredItem.GetType.Name = "ClsMMNodeForNewLink" Then
                        MoLastHoveredItem = LoActualHoveredItem
                    End If
                Else
                    MoLastHoveredItem = LoActualHoveredItem
                End If
            End If
        End If
    End Sub


    'perform zooming or scrolling
    Private Sub fcDiagramView_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles fcDiagramView.MouseWheel
        Try
            If Control.ModifierKeys = Keys.Control Then
                'zooming
                ZoomCanvasToPointFromCursor(Cursor.Position, 3 * e.Delta)
            Else
                'vertical scrolling
                ScrollCanvas(0, IIf(e.Delta < 0, 20, -20)) 'or Zoom(0, -(e.Delta / Math.Abs(e.Delta) * 20))
                'this oddity (-(e.Delta / Math.Abs(e.Delta)) makes value for zooming with right sign (+ or -)
            End If
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'perform click action (zooming, tables row properties, context menu,...)
    Private Sub fcDiagramView_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles fcDiagramView.MouseClick
        Select Case e.Button
            Case Windows.Forms.MouseButtons.Left
                'zooming secondary operation
                Select Case MoHand.SecondaryOperation
                    Case GeSecondaryOperationOfHand.kkZoom
                        Me.fcDiagramView.PointerCursor = New Cursor(Me.GetType(), "MagnGlassNORMAL.cur")
                        ZoomCanvasToPointFromCursor(Cursor.Position, 500)
                        Me.fcDiagramView.PointerCursor = New Cursor(Me.GetType(), "MagnGlassPLUS.cur")
                End Select
            Case Windows.Forms.MouseButtons.Right
                If MoHand.SecondaryOperation <> GeSecondaryOperationOfHand.kkIdle Then
                    'perform secondary operation
                    Select Case MoHand.SecondaryOperation
                        Case GeSecondaryOperationOfHand.kkZoom
                            Me.fcDiagramView.PointerCursor = New Cursor(Me.GetType(), "MagnGlassNORMAL.cur")
                            ZoomCanvasToPointFromCursor(Cursor.Position, -500)
                            Me.fcDiagramView.PointerCursor = New Cursor(Me.GetType(), "MagnGlassMINUS.cur")
                    End Select
                Else
                    'show popup menu for table
                    Dim LoItem As DiagramItem = fcDiagram.GetItemAt(fcDiagramView.ClientToDoc(e.Location), True)

                    If LoItem IsNot Nothing Then
                        Select Case LoItem.GetType.Name
                            Case "ClsMMTableNode"
                                ShowPopupMenu(GeTypeOfPopupMenu.kkNodeContext, fcDiagramView.PointToScreen(e.Location))
                            Case "ClsMMContainerNode"
                                ShowPopupMenu(GeTypeOfPopupMenu.kkUnitContext, fcDiagramView.PointToScreen(e.Location))
                        End Select
                    End If
                End If
        End Select
    End Sub
    'drag over fcDiagramView event
    Private Sub fcDiagramView_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles fcDiagramView.DragOver
        Try
            If e.Data.GetDataPresent(GoDummyUcnListBoxItem.GetType()) Then
                Dim LoUcnListBoxItem As ClsUcnListBoxItem = e.Data.GetData(GoDummyUcnListBoxItem.GetType)
                'if table is added, find out if it is dragged over container
                If LoUcnListBoxItem.Data = GeTypeOfItems.kkTable Or LoUcnListBoxItem.Data = GeTypeOfItems.kkTemplateTable Then
                    Dim pt As Point = fcDiagramView.PointToClient(New Point(e.X, e.Y))
                    Dim ptF As PointF = fcDiagramView.ClientToDoc(New Point(pt.X, pt.Y))
                    If AllowDropNodeToContainer(ptF) IsNot Nothing Then
                        e.Effect = DragDropEffects.Copy
                    Else
                        e.Effect = DragDropEffects.None
                    End If
                Else
                    e.Effect = DragDropEffects.Copy
                End If
            Else
                e.Effect = DragDropEffects.None
            End If
        Catch ex As Exception
            LogEventFromException(ex, , , )
            e.Effect = DragDropEffects.None
        End Try
    End Sub
    'drag drop fcDiagramView event
    Private Sub fcDiagramView_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles fcDiagramView.DragDrop
        Try
            If e.Data.GetDataPresent(GoDummyUcnListBoxItem.GetType()) Then
                Dim LoPoint As Point = fcDiagramView.PointToClient(New Point(e.X, e.Y))
                Dim LoPointF As PointF = fcDiagramView.ClientToDoc(New Point(LoPoint.X, LoPoint.Y))

                Dim LoUcnListBoxItem As ClsUcnListBoxItem = e.Data.GetData(GoDummyUcnListBoxItem.GetType)
                Dim LeResult As GeActionResult = GeActionResult.kkError
                Dim LbAddTable As Boolean = False 'true if table is adding
                Dim LbAddTemplate As Boolean = False 'true if template is adding
                Dim LoNode As DiagramNode = Nothing

                Dim LoContainerForTable As ClsMMContainerNode = Nothing

                Dim LoAction As ClsAction = New ClsAction(GeAction.kkAddItemToDiagram)

                Select Case LoUcnListBoxItem.Data
                    Case GeTypeOfItems.kkNone
                        LoNode = Nothing
                    Case GeTypeOfItems.kkTable
                        LoContainerForTable = AllowDropNodeToContainer(LoPointF)
                        If LoContainerForTable IsNot Nothing Then
                            LbAddTable = True
                            Dim LsNameOfContainer As String = LoContainerForTable.Caption
                            LoNode = CreateNewNode(GeTypeOfItems.kkTable)
                            LoAction.SetData("TRIEDA", "ORIGINALAPPTABLENAME")
                            LoAction.SetData("Trieda", "ORIGINALHUMANTABLENAME")
                            LoAction.SetData(LoContainerForTable, "CONTAINER")
                        Else
                            Debug.Print("CHYBA!!! - fcDiagramView_DragDrop - Case kkTable")
                        End If
                    Case GeTypeOfItems.kkContainer
                        LoNode = CreateNewNode(GeTypeOfItems.kkContainer)
                        LoAction.SetData("FORMULAR", "ORIGINALCONTAINERNAME")
                        LoAction.SetData("Formular", "ORIGINALHUMANCONTAINERNAME")
                        LoAction.SetData("TRIEDA", "ORIGINALAPPTABLENAME")
                        LoAction.SetData("Trieda", "ORIGINALHUMANTABLENAME")
                    Case GeTypeOfItems.kkModule
                        LoNode = CreateNewNode(GeTypeOfItems.kkModule)
                        LoAction.SetData("Modul", "ORIGINALMODULENAME")
                    Case GeTypeOfItems.kkNote
                        LoNode = CreateNewNode(GeTypeOfItems.kkNote)
                    Case GeTypeOfItems.kkTemplateTable
                        LoContainerForTable = AllowDropNodeToContainer(LoPointF)
                        If LoContainerForTable IsNot Nothing Then
                            LbAddTable = True
                            LbAddTemplate = True
                            Dim LsNameOfContainer As String = LoContainerForTable.Caption
                            ''''LoNode = UcnNodesToolbarUC.GetTemplate(UcnNodesToolbarUC.GetNameOfTemplate)
                            Dim LoNodeNew As ClsMMTableNode = New ClsMMTableNode(LoNode)
                            LoNode = LoNodeNew
                            LoAction.SetData(LoNodeNew.Caption, "ORIGINALAPPTABLENAME")
                            LoAction.SetData("Trieda", "ORIGINALHUMANTABLENAME")
                            LoAction.SetData(LoContainerForTable, "CONTAINER")
                        End If
                    Case GeTypeOfItems.kkActor
                        LoNode = CreateNewNode(GeTypeOfItems.kkActor)
                        LoAction.SetData("Akter", "ORIGINALACTORNAME")
                    Case GeTypeOfItems.kkActivity
                        LoNode = CreateNewNode(GeTypeOfItems.kkActivity)
                        LoAction.SetData("Aktivita", "ORIGINALACTIVITYNAME")
                    Case GeTypeOfItems.kkSystemBoundary
                        LoNode = CreateNewNode(GeTypeOfItems.kkSystemBoundary)
                        LoAction.SetData("System", "ORIGINALSYSTEMBOUNDARYNAME")
                    Case Else
                        LoNode = Nothing
                        Debug.Print("CHYBA!!! - fcDiagramView_DragDrop - Select Case")
                End Select

                If LoNode IsNot Nothing Then
                    LoNode.Bounds = SDRectangleFVirginCreator(LoPointF.X, LoPointF.Y, LoNode.Bounds.Width, LoNode.Bounds.Height)
                    'add item to DS and then to the diagram
                    LoAction.SetData(LoNode, "ITEM")
                    LeResult = Execute(LoAction)
                End If

                ''DOCASNE''
                ' ''If LeResult = GeActionResult.kkOk And LbAddTemplate Then
                ' ''    'in case of adding template add rows to DS
                ' ''    Dim LoClsTableNode As ClsMMTableNode = CType(LoNode, ClsMMTableNode)
                ' ''    Dim LoDataTable As DataTable = CType(LoClsTableNode.Tag, DataTable)
                ' ''    'clearing tag
                ' ''    LoClsTableNode.Tag = Nothing

                ' ''    Try
                ' ''        For Each LoDataRow As DataRow In LoDataTable.Rows
                ' ''            Dim LoNewRow As DataRow = MoDSaModFile.DSaModActualVersion.Tables("_a_Columns").NewRow
                ' ''            LoNewRow.ItemArray = LoDataRow.ItemArray
                ' ''            'LoNewRow.Item("AppTableName") = LoClsTableNode.Caption
                ' ''            LoNewRow.Item("TableName") = MoDSaModFile.MakeTableNameFromAppTableName(LoClsTableNode.Caption)
                ' ''            MoDSaModFile.DSaModActualVersion.Tables("_a_Columns").Rows.Add(LoNewRow)
                ' ''        Next
                ' ''    Catch ex As Exception
                ' ''        Debug.Print("CHYBA!!! - table from toolbar")
                ' ''    End Try
                ' ''End If
            End If
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'keydown on fcDiagramView
    Private Sub fcDiagramView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles fcDiagramView.KeyDown
        'only for delete key!
        Select Case e.KeyCode
            Case Keys.Delete 'DEL
                If Me.fcDiagram.Selection.Items.Count > 0 Then
                    Dim LoAction As ClsAction = New ClsAction(GeAction.kkRemoveDiagramSelection)
                    Execute(LoAction)
                End If
        End Select
    End Sub
    'keypress on fcDiagramView
    Private Sub fcDiagramView_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles fcDiagramView.KeyPress
        Select Case Asc(e.KeyChar)
            Case Keys.Escape 'ESC
                'cancel zoom secondary operation
                If MoHand.SecondaryOperation = GeSecondaryOperationOfHand.kkZoom Then
                    MoHand.SecondaryOperation = GeSecondaryOperationOfHand.kkIdle
                End If
        End Select
    End Sub
#End Region
#Region "fcDiagram - Events handler"
    'drawing a table cell - draw RTF row note indicator
    Private Sub fcDiagram_DrawCell(ByVal sender As Object, ByVal e As MindFusion.Diagramming.DrawCellEventArgs) Handles fcDiagram.DrawCell
        Dim LiNumberOfColumns As Integer = e.Table.Columns.Count - 1

        If e.Column = LiNumberOfColumns Then
            'drawing a cell of the last column
            Dim LoMMTableNode As ClsMMTableNode = CType(e.Table, ClsMMTableNode)
            If LoMMTableNode.MMGetRTFnoteRowIndicator(e.Row) Then
                DrawNoteTriangle(e.Bounds, e.Graphics)
            End If
        End If
    End Sub
    'cell clicked
    Private Sub fcDiagram_CellClicked(ByVal sender As Object, ByVal e As MindFusion.Diagramming.CellEventArgs) Handles fcDiagram.CellClicked
        Dim LoMMTableNode As ClsMMTableNode = e.Table
        If MoHand.SecondaryOperation = GeSecondaryOperationOfHand.kkIdle Then
            If LoMMTableNode IsNot Nothing Then
                LoMMTableNode.HighlightedRow = e.Row
                RefreshSelectedItemProperties(LoMMTableNode, True)
            End If
        End If
    End Sub
    'node clicked - process table vs table row selection
    Private Sub fcDiagram_NodeClicked(ByVal sender As Object, ByVal e As MindFusion.Diagramming.NodeEventArgs) Handles fcDiagram.NodeClicked
        If e.Node.GetType.Name = "ClsMMTableNode" Then
            Dim LoMMTableNode As ClsMMTableNode = e.Node
            LoMMTableNode.HighlightedRow = -1
            RefreshSelectedItemProperties(LoMMTableNode, True)
        End If
    End Sub
    'open module after doubleclick
    Private Sub fcDiagram_NodeDoubleClicked(ByVal sender As Object, ByVal e As MindFusion.Diagramming.NodeEventArgs) Handles fcDiagram.NodeDoubleClicked
        Try
            Select Case e.Node.GetType.Name
                Case "ClsMMModuleNode"
                    Dim LoMMModuleNode As ClsMMModuleNode = CType(e.Node, ClsMMModuleNode)
                    Dim LsModuleName As String = LoMMModuleNode.ModuleName
                    Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModTryToOpenVersions)

                    Dim LoVersions As Collection = New Collection
                    LoVersions.Add(-1)
                    '-1 = last version

                    LoAction.SetData(LoVersions, "VERSIONS")
                    'LoAction.SetData(LsModuleName, "MODULENAME")
                    LoAction.SetData(MoDSaModSolutionFile.GetAmodFilePath(LsModuleName), "PATHTOFILE")
                    Execute(LoAction)
            End Select
        Catch ex As Exception
            LogEventFromException(ex, , )
        End Try
    End Sub
    'initialization of node
    Private Sub fcDiagram_InitializeNode(ByVal sender As Object, ByVal e As MindFusion.Diagramming.NodeEventArgs) Handles fcDiagram.InitializeNode
        If MoHand.SecondaryOperation <> GeSecondaryOperationOfHand.kkIdle Then
            'there is any secondary operation
            Select Case MoHand.SecondaryOperation
                Case GeSecondaryOperationOfHand.kkZoom
                    Me.fcDiagramView.PointerCursor = New Cursor(Me.GetType(), "MagnGlassRECTANGLE.cur")
                    Dim LoNode As ShapeNode = CType(e.Node, ShapeNode)
                    LoNode.Shape = Shapes.Rectangle
                    LoNode.Pen = New Pen(Color.LightGray, 1)
                    LoNode.Brush = New SolidBrush(Color.Transparent)
                    LoNode.ShadowColor = Color.Transparent
                    LoNode.Text = "Tahanim zvolte oblast pre priblizenie..."
                Case Else
                    Debug.Print("CHYBA!!! - fcDiagram_InitializeNode")
            End Select
        Else
            'some node is creating
            Select Case e.Node.GetType.Name
                Case "ClsMMTableNode"
                    CType(e.Node, ClsMMTableNode).MMSetDefaultProperties()
                Case "ClsMMContainerNode"
                    CType(e.Node, ClsMMContainerNode).MMSetDefaultProperties()
            End Select
        End If
    End Sub
    'perform secondary zooming operation 
    Private Sub fcDiagram_NodeCreated(ByVal sender As Object, ByVal e As MindFusion.Diagramming.NodeEventArgs) Handles fcDiagram.NodeCreated
        If MoHand.SecondaryOperation <> GeSecondaryOperationOfHand.kkIdle Then
            Select Case MoHand.SecondaryOperation
                Case GeSecondaryOperationOfHand.kkZoom
                    Dim LoNode As ShapeNode = CType(e.Node, ShapeNode)
                    fcDiagramView.ZoomToRect(LoNode.Bounds)
                    fcDiagram.Nodes.Remove(LoNode)
                    Me.fcDiagramView.PointerCursor = New Cursor(Me.GetType(), "MagnGlassNORMAL.cur")
                Case Else
                    Debug.Print("CHYBA!!! - fcDiagram_NodeCreated")
            End Select
        End If
    End Sub
    'perform fitting of size of table for any types of modification
    Private Sub fcDiagram_NodeModifying(ByVal sender As Object, ByVal e As MindFusion.Diagramming.NodeValidationEventArgs) Handles fcDiagram.NodeModifying
        SetFileWasModified(True)
        If e.Node.GetType.Name = "ClsMMActorNode" AndAlso (e.AdjustmentHandle = AdjustmentHandles.ResizeBottomLeft Or e.AdjustmentHandle = AdjustmentHandles.ResizeBottomRight Or e.AdjustmentHandle = AdjustmentHandles.ResizeMiddleLeft Or e.AdjustmentHandle = AdjustmentHandles.ResizeMiddleRight Or e.AdjustmentHandle = AdjustmentHandles.ResizeTopLeft Or e.AdjustmentHandle = AdjustmentHandles.ResizeTopRight) Then
            CType(e.Node, ClsMMActorNode).MMResizeTextArea()
        End If

        Select Case e.AdjustmentHandle
            Case AdjustmentHandles.ResizeBottomCenter, AdjustmentHandles.ResizeBottomLeft, AdjustmentHandles.ResizeBottomRight, _
                 AdjustmentHandles.ResizeMiddleLeft, AdjustmentHandles.ResizeMiddleRight, _
                 AdjustmentHandles.ResizeTopCenter, AdjustmentHandles.ResizeTopLeft, AdjustmentHandles.ResizeTopRight
                Select Case e.Node.GetType.Name
                    Case "ClsMMTableNode"
                        CType(e.Node, ClsMMTableNode).MMResizeAllToFitTable(False)
                    Case "ClsMMContainerNode"
                        CType(e.Node, ClsMMContainerNode).MMResizeHeightOfCaption()
                End Select
            Case AdjustmentHandles.Move
                Select Case e.Node.GetType.Name
                    Case "ClsMMTableNode"
                        Dim LoPointF As PointF = fcDiagramView.ClientToDoc(fcDiagramView.PointToClient(Control.MousePosition))
                        Dim LoContainerForTable As ClsMMContainerNode = AllowDropNodeOutsideOfContainer(LoPointF)

                        If LoContainerForTable Is Nothing Then
                            e.Cancel = True
                            Debug.Print("nastavujem TRUE")
                        Else
                            e.Cancel = False
                            Debug.Print("nastavujem FALSE")
                            Me.fcDiagramView.CurrentCursor = Cursors.SizeAll
                        End If

                        Debug.Print(e.Cancel)
                End Select
        End Select
    End Sub
    'resize node after resizing (by moving or resizing)
    Private Sub fcDiagram_NodeModified(ByVal sender As Object, ByVal e As MindFusion.Diagramming.NodeEventArgs) Handles fcDiagram.NodeModified
        ''DOCASNE'' - dat podmienky, kedy sa co resizuje, bo sa to teraz vola casto
        Select Case e.Node.GetType.Name
            Case "ClsMMTableNode"
                CType(e.Node, ClsMMTableNode).MMResizeAllToFitTable(True) 'resizing table and parent container
            Case "ClsMMContainerNode"
                'CType(e.Node, ClsMMContainerNode).MMResizeHeightOfCaption() 'resize height of container caption
        End Select
    End Sub
    'cancel selection of node if secondary operation is ZOOM
    Private Sub fcDiagram_NodeSelecting(ByVal sender As Object, ByVal e As MindFusion.Diagramming.NodeValidationEventArgs) Handles fcDiagram.NodeSelecting
        If MoHand.SecondaryOperation = GeSecondaryOperationOfHand.kkZoom Then e.Cancel = True
    End Sub
    'deselecting row of table
    Private Sub fcDiagram_NodeDeactivated(ByVal sender As Object, ByVal e As MindFusion.Diagramming.NodeEventArgs) Handles fcDiagram.NodeDeactivated
        Dim LoItem As DiagramItem = e.Node
        If LoItem IsNot Nothing Then
            Select Case LoItem.GetType.Name
                Case "ClsMMTableNode"
                    'deselecting row of table
                    Dim LoMMTableNode As ClsMMTableNode = CType(LoItem, ClsMMTableNode)
                    LoMMTableNode.HighlightedRow = -1
            End Select
        End If
    End Sub
    'set type of link and its default properties
    Private Sub fcDiagram_InitializeLink(ByVal sender As Object, ByVal e As MindFusion.Diagramming.LinkEventArgs) Handles fcDiagram.InitializeLink
        Dim LoMMLinkNode As ClsMMLinkNode = CType(e.Link, ClsMMLinkNode)

        'setting type of link
        Select Case e.Link.Origin.GetType.Name
            Case "ClsMMTableNode"
                LoMMLinkNode.MMTypeOfLink = GeTypeOfLink.kkClassDiagramRelationship
                LoMMLinkNode.MMRelationType = MoHand.TypeOfLink
            Case "ClsMMNoteNode"
                LoMMLinkNode.MMTypeOfLink = GeTypeOfLink.kkNote
                LoMMLinkNode.MMRelationType = KrosLib.Data.eRelationType.None
            Case "ClsMMActivityNode", "ClsMMActorNode"
                LoMMLinkNode.MMTypeOfLink = GeTypeOfLink.kkUseCaseRelationship
                LoMMLinkNode.MMRelationType = MoHand.TypeOfLink
            Case Else
                Debug.Print("CHYBA!!! - fcDiagram_InitializeLink")
        End Select
    End Sub
    'prevent to create loop link while creating a link
    Private Sub fcDiagram_LinkCreating(ByVal sender As Object, ByVal e As MindFusion.Diagramming.LinkValidationEventArgs) Handles fcDiagram.LinkCreating
        Dim LoMMLinkNode As ClsMMLinkNode = CType(e.Link, ClsMMLinkNode)
        e.Cancel = Not CheckLinkRules(LoMMLinkNode, e.Node, e.Origin, e.Destination, False)
    End Sub
    'set links properties after link is created
    Private Sub fcDiagram_LinkCreated(ByVal sender As Object, ByVal e As MindFusion.Diagramming.LinkEventArgs) Handles fcDiagram.LinkCreated
        Dim LoMMLinkNode As ClsMMLinkNode = CType(e.Link, ClsMMLinkNode)

        Select Case LoMMLinkNode.MMTypeOfLink
            Case GeTypeOfLink.kkClassDiagramRelationship
                Dim LoAction As ClsAction = New ClsAction(GeAction.kkAddLinkToDiagram)
                LoAction.SetData(LoMMLinkNode, "LINK")

                If Execute(LoAction) = GeActionResult.kkOk Then
                    'setting new settings after link is created
                    LoMMLinkNode.SnapToNodeBorder = True
                    LoMMLinkNode.AutoRoute = True
                    LoMMLinkNode.Style = LinkStyle.Cascading
                Else
                    'deleting link after unsuccessfully added to dataset
                    Me.fcDiagram.Links.Remove(LoMMLinkNode)
                End If
            Case GeTypeOfLink.kkUseCaseRelationship
                'setting new settings after link is created
                Select Case LoMMLinkNode.MMRelationType
                    Case GeTypeOfRelationship.kkUseCaseDiagramAssociation
                        LoMMLinkNode.SnapToNodeBorder = True
                        LoMMLinkNode.AutoRoute = False
                        LoMMLinkNode.Style = LinkStyle.Polyline
                    Case GeTypeOfRelationship.kkUseCaseDiagramAssociation
                        LoMMLinkNode.SnapToNodeBorder = True
                        LoMMLinkNode.AutoRoute = False
                        LoMMLinkNode.Style = LinkStyle.Polyline
                    Case GeTypeOfRelationship.kkUseCaseDiagramAssociation
                        LoMMLinkNode.SnapToNodeBorder = True
                        LoMMLinkNode.AutoRoute = False
                        LoMMLinkNode.Style = LinkStyle.Polyline
                End Select
                SetFileWasModified(True)
            Case GeTypeOfLink.kkNote
                'setting new settings after link is created
                LoMMLinkNode.SnapToNodeBorder = True
                LoMMLinkNode.AutoRoute = False
                LoMMLinkNode.Style = LinkStyle.Polyline
                SetFileWasModified(True)
            Case GeTypeOfLink.kkJoinedModuleRelationship
                'setting new settings after link is created
                LoMMLinkNode.SnapToNodeBorder = True
                LoMMLinkNode.AutoRoute = False
                LoMMLinkNode.Style = LinkStyle.Polyline
                SetFileWasModified(True)
            Case Else
                Debug.Print("CHYBA!!! - fcDiagram_LinkCreated")
        End Select
    End Sub
    'prevent to create loop link while modifying a link
    Private Sub fcDiagram_LinkModifying(ByVal sender As Object, ByVal e As MindFusion.Diagramming.LinkValidationEventArgs) Handles fcDiagram.LinkModifying
        Dim LoMMLinkNode As ClsMMLinkNode = CType(e.Link, ClsMMLinkNode)
        e.Cancel = Not CheckLinkRules(LoMMLinkNode, e.Node, e.Origin, e.Destination, True)
    End Sub
    'resize item after it was added to diagram. Raised when an item is added to the diagram, either programmatically or interactively!
    'setting flag for made changes 
    Private Sub fcDiagram_ItemAdded(ByVal sender As Object, ByVal e As MindFusion.Diagramming.ItemEventArgs) Handles fcDiagram.ItemAdded
        Select Case e.Item.GetType.Name
            Case "ClsMMTableNode"
                CType(e.Item, ClsMMTableNode).MMResizeAllToFitTable()
        End Select
        'setting flag for made changes - its here coz there can be change from "outside" - creating diagram after export etc
        SetFileWasModified(True)
    End Sub
    'setting flag for made changes 
    Private Sub fcDiagram_ItemRemoved(ByVal sender As Object, ByVal e As MindFusion.Diagramming.ItemEventArgs) Handles fcDiagram.ItemRemoved
        'setting flag for made changes - its here coz there can be change from "outside" - creating diagram after export etc
        SetFileWasModified(True)
    End Sub
    'node was added to container
    Private Sub fcDiagram_ContainerChildAdded(ByVal sender As Object, ByVal e As MindFusion.Diagramming.ContainerChildEventArgs) Handles fcDiagram.ContainerChildAdded
        If e.Container.GetType.Name = "ClsMMContainerNode" Then CType(e.Container, ClsMMContainerNode).MMResizeAllToFitContainer()
    End Sub
    'node was removed from container
    Private Sub fcDiagram_ContainerChildRemoved(ByVal sender As Object, ByVal e As MindFusion.Diagramming.ContainerChildEventArgs) Handles fcDiagram.ContainerChildRemoved
        If e.Container.GetType.Name = "ClsMMContainerNode" Then CType(e.Container, ClsMMContainerNode).MMResizeAllToFitContainer()
    End Sub
    'check if actual validating anchorpoint is valid (free) for accepting a new link
    'ATTENTION! Raised when shape is moving too !!!
    Private Sub fcDiagram_ValidateAnchorPoint(ByVal sender As Object, ByVal e As MindFusion.Diagramming.LinkValidationEventArgs) Handles fcDiagram.ValidateAnchorPoint
        If Not IsFreeAnchorPoint(e.Node, e.Link, e.AnchorIndex, 1) Then
            e.Cancel = True
        End If
    End Sub
    'refresh selected item properties in properties treelist
    Private Sub fcDiagram_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles fcDiagram.SelectionChanged
        RefreshSelectedItemProperties(Me.fcDiagram.ActiveItem, True)
    End Sub
#End Region
#Region "Zoom - Events handler"
    'switching on zomming
    ' ''Private Sub barBtnZoomRectangle_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnZoomRectangle.ItemClick
    ' ''    MoHand.SecondaryOperation = GeSecondaryOperationOfHand.kkZoom
    ' ''End Sub
#End Region
#Region "MoUcnPropertiesOfItemUC - Events handler"
    Private Sub MoUcnPropertiesOfItemUC_MMSettings() Handles MoUcnPropertiesOfItemUC.MMSettings
        MoUcnPropertiesOfItemUC.tlTreeList.OptionsView.ShowIndicator = False
        MoUcnPropertiesOfItemUC.tlTreeList.OptionsSelection.EnableAppearanceFocusedCell = False
        MoUcnPropertiesOfItemUC.tlTreeList.OptionsSelection.EnableAppearanceFocusedRow = False
        MoUcnPropertiesOfItemUC.tlTreeList.OptionsView.ShowColumns = False
        MoUcnPropertiesOfItemUC.tlTreeList.OptionsView.ShowCheckBoxes = False
        MoUcnPropertiesOfItemUC.tlTreeList.OptionsView.ShowRoot = False
    End Sub
    Private Sub MoUcnPropertiesOfItemUC_MMCreateDataSource() Handles MoUcnPropertiesOfItemUC.MMCreateDataSource
        'ATTENTION: keep the same order here and during adding rows to DataSource
        MoUcnPropertiesOfItemUC.tlTreeList.Columns.Add()
        MoUcnPropertiesOfItemUC.tlTreeList.Columns(0).FieldName = "RowID"
        MoUcnPropertiesOfItemUC.tlTreeList.Columns.Add()
        MoUcnPropertiesOfItemUC.tlTreeList.Columns(1).FieldName = "ParentRowID"
        MoUcnPropertiesOfItemUC.tlTreeList.Columns.Add()
        MoUcnPropertiesOfItemUC.tlTreeList.Columns(2).FieldName = "Enabled"
        MoUcnPropertiesOfItemUC.tlTreeList.Columns.Add()
        MoUcnPropertiesOfItemUC.tlTreeList.Columns(3).FieldName = "Selected"
        MoUcnPropertiesOfItemUC.tlTreeList.Columns.Add()
        MoUcnPropertiesOfItemUC.tlTreeList.Columns(4).FieldName = "PropertyName"
        MoUcnPropertiesOfItemUC.tlTreeList.Columns.Add()
        MoUcnPropertiesOfItemUC.tlTreeList.Columns(5).FieldName = "PropertyValue"

        MoUcnPropertiesOfItemUC.tlTreeList.Columns(4).VisibleIndex = 1
        MoUcnPropertiesOfItemUC.tlTreeList.Columns(5).VisibleIndex = 2
        '"RowID" AND "ParentRowID" ARE UNIQUE IDENTIFIERS FOR TREELIST AND THESE COLUMNS ARE INVISIBLE IN TREELIST COZ THEY ARE SET TO PROPERTIES KeyFieldName and ParentFieldName PROPERTIES OF TREELIST
    End Sub
    Private Sub MoUcnPropertiesOfItemUC_MMColumnProperties(ByRef Column As DevExpress.XtraTreeList.Columns.TreeListColumn) Handles MoUcnPropertiesOfItemUC.MMColumnProperties
        Try
            Select Case Column.FieldName
                Case "PropertyName"
                    Column.OptionsColumn.AllowEdit = False
                Case "PropertyValue"
                    Column.OptionsColumn.AllowEdit = True
                Case Else
                    'Column.Caption will be the same like Column.FieldName
                    Column.VisibleIndex = -1
                    Column.OptionsColumn.AllowEdit = False
            End Select
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    Private Sub MoUcnPropertiesOfItemUC_MMFillDataSource(ByVal Item As Object, ByRef DataSource As Collection) Handles MoUcnPropertiesOfItemUC.MMFillDataSource
        Try
            If Item IsNot Nothing Then
                Select Case Item.GetType.Name
                    Case "ClsMMTableNode"
                        Dim LoMMTableNode As ClsMMTableNode = CType(Item, ClsMMTableNode)

                        MoUcnPropertiesOfItemUC.MMTag = "TABLE"
                        DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Analyticky nazov", LoMMTableNode.Caption))
                        DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(1, -1, True, False, "Programatorsky nazov", LoMMTableNode.AppTableName))
                    Case "ClsMMContainerNode"
                        Dim LoMMContainerNode As ClsMMContainerNode = CType(Item, ClsMMContainerNode)

                        MoUcnPropertiesOfItemUC.MMTag = "UNIT"
                        DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Analyticky nazov", LoMMContainerNode.Caption))
                        DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(1, -1, True, False, "Programatorsky nazov", LoMMContainerNode.UnitName))
                    Case "ClsMMLinkNode"
                        Dim LoMMLinkNode As ClsMMLinkNode = CType(Item, ClsMMLinkNode)

                        Select Case LoMMLinkNode.MMTypeOfLink
                            Case GeTypeOfLink.kkClassDiagramRelationship
                                MoUcnPropertiesOfItemUC.MMTag = "CLASSMODELRELATIONSHIPLINK"
                                Dim LoMMDestinationTableNode As ClsMMTableNode = CType(LoMMLinkNode.Destination, ClsMMTableNode)
                                DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Nazov vztahu", AmodVersion.GetRelationshipName(LoMMDestinationTableNode.AppTableName)))
                            Case GeTypeOfLink.kkNote
                                MoUcnPropertiesOfItemUC.MMTag = "NOTELINK"
                                DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Nazov spojenia", LoMMLinkNode.Text))
                            Case GeTypeOfLink.kkUseCaseRelationship
                                MoUcnPropertiesOfItemUC.MMTag = "USECASERELATIONSHIP"
                                DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Nazov vztahu", LoMMLinkNode.Text))
                            Case GeTypeOfLink.kkJoinedModuleRelationship
                                MoUcnPropertiesOfItemUC.MMTag = "JOINEDMODULERELATIONSHIP"
                                DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Pocet", LoMMLinkNode.Text))
                        End Select
                    Case "ClsMMModuleNode"
                        Dim LoMMModuleNode As ClsMMModuleNode = CType(Item, ClsMMModuleNode)

                        MoUcnPropertiesOfItemUC.MMTag = "MODUL"
                        DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Analyticky nazov", LoMMModuleNode.Text))
                        DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(1, -1, True, False, "Programatorsky nazov", LoMMModuleNode.ModuleName))
                    Case "ClsMMActorNode"
                        Dim LoMMActorNode As ClsMMActorNode = CType(Item, ClsMMActorNode)

                        MoUcnPropertiesOfItemUC.MMTag = "ACTOR"
                        DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Akter", CType(LoMMActorNode.SubordinateGroup.AttachedNodes(1), ClsMMTextNode).Text))
                    Case "ClsMMActivityNode"
                        Dim LoMMActivityNode As ClsMMActivityNode = CType(Item, ClsMMActivityNode)

                        MoUcnPropertiesOfItemUC.MMTag = "ACTIVITY"
                        DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Aktivita", LoMMActivityNode.Text))
                    Case "ClsMMSystemBoundaryNode"
                        Dim LoMMSystemBoundaryNode As ClsMMSystemBoundaryNode = CType(Item, ClsMMSystemBoundaryNode)

                        MoUcnPropertiesOfItemUC.MMTag = "SYSTEMBOUNDARY"
                        DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Hranica systemu", LoMMSystemBoundaryNode.Caption))
                    Case "UcnDiagramCanvasBase"
                        Dim LoUcnDiagramCanvasBase As UcnDiagramCanvasBase = CType(Item, UcnDiagramCanvasBase)
                        Select Case LoUcnDiagramCanvasBase.MoTabPage.TypeOfTab
                            Case GeTypeOfTab.kkClassDiagramTab, GeTypeOfTab.kkVersionComparisonTab
                                MoUcnPropertiesOfItemUC.MMTag = "MODULEVERSION"
                                DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Analyticky nazov", LoUcnDiagramCanvasBase.DSaModFile.GetLastVersionHumanModuleName()))
                                DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(1, -1, True, False, "Programatorsky nazov", LoUcnDiagramCanvasBase.DSaModFile.GetLastVersionModuleName()))
                                DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(3, -1, True, False, "Nazov verzie", LoUcnDiagramCanvasBase.DSaModFile.GetVersionName(AmodVersion.GetVersionVID)))
                            Case GeTypeOfTab.kkMainTab
                                MoUcnPropertiesOfItemUC.MMTag = "SOLUTION"
                                'DataSource.Add(New Object() {0, -1, "Nazov projektu", LoUcnDiagramCanvasBase.DSaModSolutionFile.GetSolutionName})
                                DataSource.Add(New ClsUcnGridUnboundItemPropertiesOfItem(0, -1, True, False, "Nazov projektu", LoUcnDiagramCanvasBase.DSaModSolutionFile.GetSolutionName))
                            Case GeTypeOfTab.kkUseCaseTab
                                'do nothing
                        End Select
                    Case Else
                        Debug.Print("CHYBA!!! - MoUcnPropertiesOfItemUC_MMFill")
                End Select
            End If

        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    Private Sub MoUcnPropertiesOfItemUC_MMShowingEditor(ByVal e As System.ComponentModel.CancelEventArgs) Handles MoUcnPropertiesOfItemUC.MMShowingEditor
        e.Cancel = MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab Or MoUcnPropertiesOfItemUC.MMTag = "JOINEDMODULERELATIONSHIP"
    End Sub
    Private Sub MoUcnPropertiesOfItemUC_MMValueValidating(ByVal Item As Object, ByVal Row As DevExpress.XtraTreeList.Nodes.TreeListNode, ByVal Column As DevExpress.XtraTreeList.Columns.TreeListColumn, ByRef Value As Object, ByRef Valid As Boolean, ByRef ErrorText As String) Handles MoUcnPropertiesOfItemUC.MMValueValidating
        Select Case MoUcnPropertiesOfItemUC.MMTag
            Case "TABLE"
                'table
                Select Case Row.GetValue("RowID")
                    Case 0
                        'analytic name
                        Dim LeResult As GeActionResult = GeActionResult.kkOk
                        Dim LoMMTableNode As ClsMMTableNode = CType(Item, ClsMMTableNode)
                        Dim LsNewHumanTableName As String = CStr(Value)
                        LeResult = AmodVersion.UpdateHumanTableName(LoMMTableNode.AppTableName, LsNewHumanTableName)

                        'rebuild child tables after its FK was changed
                        Dim LoOutgoingLinks As Collection = LoMMTableNode.MMGetRelationshipsLinks(False)
                        Dim LoChildMMTableNode As ClsMMTableNode = Nothing
                        For Each LoMMLinkNode As ClsMMLinkNode In LoOutgoingLinks
                            LoChildMMTableNode = CType(LoMMLinkNode.Destination, ClsMMTableNode)
                            LeResult = LoChildMMTableNode.MMRebuildTable(MoAmodVersion.GetDataTableAllRowsSortedByPosition(LoChildMMTableNode.AppTableName))
                        Next

                        Select Case LeResult
                            Case GeActionResult.kkOk
                                LoMMTableNode.Caption = LsNewHumanTableName
                                LoMMTableNode.MMResizeAllToFitTable()

                                'refreshes panel in main tab with table columns info joined to module
                                If IsThisTheLastVersion Then RefreshTableColumnsJoinedToModule(DSaModFile.GetLastVersionModuleName, MoAmodVersion.GetTableListRowByAppTableName(LoMMTableNode.AppTableName)(AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName), LoMMTableNode.AppTableName, "")

                                Valid = True
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri zmene analytickeho nazvu triedy!"
                            Case GeActionResult.kkCancel
                                Valid = False
                                ErrorText = "Trieda s analytickym nazvom """ & LsNewHumanTableName & """ uz existuje!"
                        End Select
                    Case 1
                        'programmatic name
                        Dim LeResult As GeActionResult = GeActionResult.kkOk
                        Dim LoMMTableNode As ClsMMTableNode = CType(Item, ClsMMTableNode)
                        Dim LsOldAppTableName As String = LoMMTableNode.AppTableName
                        Dim LsNewAppTableName As String = FormatProgrammaticTableAndTableRowName(CStr(Value))

                        If LsNewAppTableName <> "" Then
                            LeResult = AmodVersion.UpdateAppTableName(LoMMTableNode.AppTableName, LsNewAppTableName)

                            'rebuild child tables after its FK was changed
                            Dim LoOutgoingLinks As Collection = LoMMTableNode.MMGetRelationshipsLinks(False)
                            Dim LoChildMMTableNode As ClsMMTableNode = Nothing
                            For Each LoMMLinkNode As ClsMMLinkNode In LoOutgoingLinks
                                LoChildMMTableNode = CType(LoMMLinkNode.Destination, ClsMMTableNode)
                                LeResult = LoChildMMTableNode.MMRebuildTable(MoAmodVersion.GetDataTableAllRowsSortedByPosition(LoChildMMTableNode.AppTableName))
                            Next
                        Else
                            LeResult = GeActionResult.kkError
                            MessageBox.Show("Programatorsky nazov triedy nesmie byt prazdny retazec!" & vbNewLine & vbNewLine & "Programatorsky nazov moze obsahovat iba velke pismena abecedy, znak ""_"" a cisla nie na zaciatku nazvu. Po prisposobeni Vami zadaneho nazvu je vsak vysledkom prazdny retazec.", "Neprijatelny programatorsky nazov triedy", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                        End If

                        Select Case LeResult
                            Case GeActionResult.kkOk
                                Value = LsNewAppTableName
                                LoMMTableNode.AppTableName = LsNewAppTableName

                                'refreshes panel in main tab with table columns info joined to module
                                If IsThisTheLastVersion Then RefreshTableColumnsJoinedToModule(DSaModFile.GetLastVersionModuleName, MoAmodVersion.GetTableListRowByAppTableName(LsNewAppTableName)(AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName), LsOldAppTableName, "")

                                Valid = True
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri zmene programatorskeho nazvu triedy!"
                            Case GeActionResult.kkCancel
                                Valid = False
                                ErrorText = "Trieda s programatorskym nazvom """ & LsNewAppTableName & """ uz existuje!"
                        End Select
                End Select
            Case "UNIT"
                'unit
                Select Case Row.GetValue("RowID")
                    Case 0
                        'analytic name
                        Dim LoMMContainerNode As ClsMMContainerNode = CType(Item, ClsMMContainerNode)
                        Dim LsNewHumanUnitName As String = CStr(Value)

                        Select Case AmodVersion.UpdateHumanUnitName(LoMMContainerNode.UnitName, LsNewHumanUnitName)
                            Case GeActionResult.kkOk
                                LoMMContainerNode.Caption = LsNewHumanUnitName
                                LoMMContainerNode.MMResizeAllToFitContainer()

                                'refreshes panel in main tab with table columns info joined to module
                                If IsThisTheLastVersion Then RefreshTableColumnsJoinedToModule(DSaModFile.GetLastVersionModuleName, LoMMContainerNode.UnitName, "", "")

                                Valid = True
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri zmene analytickeho nazvu unitu!"
                            Case GeActionResult.kkCancel
                                Valid = False
                                ErrorText = "Unit s analytickym nazvom """ & LsNewHumanUnitName & """ uz existuje!"
                        End Select
                    Case 1
                        'programmatic name
                        Dim LeResult As GeActionResult = GeActionResult.kkOk
                        Dim LoMMContainerNode As ClsMMContainerNode = CType(Item, ClsMMContainerNode)
                        Dim LsNewUnitName As String = FormatProgrammaticModuleAndUnitName(CStr(Value))

                        If LsNewUnitName <> "" Then
                            LeResult = AmodVersion.UpdateUnitName(LoMMContainerNode.UnitName, LsNewUnitName)
                        Else
                            LeResult = GeActionResult.kkError
                            MessageBox.Show("Programatorsky nazov unitu nesmie byt prazdny retazec!" & vbNewLine & vbNewLine & "Programatorsky nazov moze obsahovat iba male a velke pismena abecedy, znak ""_"" a cisla nie na zaciatku nazvu. Po prisposobeni Vami zadaneho nazvu je vsak vysledkom prazdny retazec.", "Neprijatelny programatorsky nazov unitu", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                        End If

                        Select Case LeResult
                            Case GeActionResult.kkOk
                                Value = LsNewUnitName
                                LoMMContainerNode.UnitName = LsNewUnitName

                                'refreshes panel in main tab with table columns info joined to module
                                If IsThisTheLastVersion Then RefreshTableColumnsJoinedToModule(DSaModFile.GetLastVersionModuleName, LoMMContainerNode.UnitName, "", "")

                                Valid = True
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri zmene programatorskeho nazvu unitu!"
                            Case GeActionResult.kkCancel
                                Valid = False
                                ErrorText = "Unit s programatorskym nazvom """ & LsNewUnitName & """ uz existuje!"
                        End Select
                End Select
            Case "MODUL"
                'modul in Maintab
                Select Case Row.GetValue("RowID")
                    Case 0
                        'analytic name
                        Dim LeResult As GeActionResult = GeActionResult.kkOk
                        Dim LoMMModuleNode As ClsMMModuleNode = CType(Item, ClsMMModuleNode)
                        Dim LsOldHumanModuleName As String = LoMMModuleNode.Text
                        Dim LsAmodFilePath As String = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAmodFilePath(LoMMModuleNode.ModuleName)

                        'change human module name also in aMod file - open it if needed
                        Dim LoDSaModFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodFilePath, True)
                        If LoDSaModFile Is Nothing Then
                            LeResult = QuickOpenAmodFile(LsAmodFilePath, LoDSaModFile)
                        End If

                        If LeResult = GeActionResult.kkOk Then
                            Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModUpdateHumanModuleName)
                            LoAction.SetData(LoDSaModFile, "AMODFILE")
                            LoAction.SetData(CStr(Value), "NEWHUMANMODULENAME")
                            LeResult = Execute(LoAction)
                        End If

                        Select Case LeResult
                            Case GeActionResult.kkOk
                                Valid = True
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri zmene analytickeho nazvu modulu!"
                            Case GeActionResult.kkCancel
                                Valid = False
                                ErrorText = "ZRUSENIE_EDITACIE"
                                MoUcnPropertiesOfItemUC.tlTreeList.HideEditor()
                            Case GeActionResult.kkSpecial
                                Valid = False
                                ErrorText = "Modul s analytickym nazvom """ & CStr(Value) & """ uz existuje!"
                        End Select
                    Case 1
                        'programmatic name
                        Dim LoMMModuleNode As ClsMMModuleNode = CType(Item, ClsMMModuleNode)
                        Dim LsOldModuleName As String = LoMMModuleNode.ModuleName
                        Dim LsNewModuleName As String = FormatProgrammaticModuleAndUnitName(CStr(Value))
                        Dim LsAmodFilePath As String = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAmodFilePath(LoMMModuleNode.ModuleName)

                        'change module name also in aMod file - open it if needed
                        Dim LeResult As GeActionResult = GeActionResult.kkOk
                        Dim LoDSaModFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodFilePath, True)
                        If LoDSaModFile Is Nothing Then
                            LeResult = QuickOpenAmodFile(LsAmodFilePath, LoDSaModFile)
                        End If

                        If LeResult = GeActionResult.kkOk Then
                            Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModUpdateModuleName)
                            LoAction.SetData(LoDSaModFile, "AMODFILE")
                            LoAction.SetData(LsNewModuleName, "NEWMODULENAME")
                            LeResult = Execute(LoAction)
                        End If

                        Select Case LeResult
                            Case GeActionResult.kkOk
                                Value = LsNewModuleName
                                Valid = True
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri zmene programatorskeho nazvu modulu!"
                            Case GeActionResult.kkCancel
                                Valid = False
                                ErrorText = "ZRUSENIE_EDITACIE"
                                MoUcnPropertiesOfItemUC.tlTreeList.HideEditor()
                            Case GeActionResult.kkSpecial
                                Valid = False
                                ErrorText = "Modul s programatorskym nazvom """ & LsNewModuleName & """ uz existuje!"
                        End Select
                End Select
            Case "MODULEVERSION"
                'modul version in tab
                Select Case Row.GetValue("RowID")
                    Case 0
                        'analytic name
                        Dim LeResult As GeActionResult = GeActionResult.kkOk
                        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModUpdateHumanModuleName)
                        LoAction.SetData(MoDSaModFile, "AMODFILE")
                        LoAction.SetData(CStr(Value), "NEWHUMANMODULENAME")
                        LeResult = Execute(LoAction)

                        Select Case LeResult
                            Case GeActionResult.kkOk
                                Valid = True
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri zmene analytickeho nazvu modulu!"
                            Case GeActionResult.kkCancel
                                Valid = False
                                ErrorText = "ZRUSENIE_EDITACIE"
                                MoUcnPropertiesOfItemUC.tlTreeList.HideEditor()
                            Case GeActionResult.kkSpecial
                                Valid = False
                                ErrorText = "Modul s analytickym nazvom """ & CStr(Value) & """ uz existuje!"
                        End Select
                    Case 1
                        'programmatic name
                        Dim LsNewModuleName As String = FormatProgrammaticModuleAndUnitName(CStr(Value))
                        Dim LeResult As GeActionResult = GeActionResult.kkOk
                        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModUpdateModuleName)
                        LoAction.SetData(MoDSaModFile, "AMODFILE")
                        LoAction.SetData(LsNewModuleName, "NEWMODULENAME")
                        LeResult = Execute(LoAction)

                        Select Case LeResult
                            Case GeActionResult.kkOk
                                Value = LsNewModuleName
                                Valid = True
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri zmene programatorskeho nazvu modulu!"
                            Case GeActionResult.kkCancel
                                Valid = False
                                ErrorText = "ZRUSENIE_EDITACIE"
                                MoUcnPropertiesOfItemUC.tlTreeList.HideEditor()
                            Case GeActionResult.kkSpecial
                                Valid = False
                                ErrorText = "Modul s programatorskym nazvom """ & LsNewModuleName & """ uz existuje!"
                        End Select
                    Case 3
                        'version name
                        Dim LsNewVersioneName As String = CStr(Value)
                        Dim LeResult As GeActionResult = GeActionResult.kkOk
                        LeResult = DSaModFile.UpdateVersionName(AmodVersion.GetVersionVID, LsNewVersioneName)

                        Select Case LeResult
                            Case GeActionResult.kkOk
                                Valid = True
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri zmene nazvu verzie modulu!"
                            Case GeActionResult.kkCancel
                                Valid = False
                                ErrorText = "ZRUSENIE_EDITACIE"
                                MoUcnPropertiesOfItemUC.tlTreeList.HideEditor()
                        End Select
                End Select
            Case "SOLUTION"
                Select Case Row.GetValue("RowID")
                    Case 0
                        Dim LsNewSolutionName As String = CStr(Value)
                        Dim LeResult As GeActionResult = GeActionResult.kkOk
                        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModSolutionUpdateSolutionName)
                        LoAction.SetData(LsNewSolutionName, "NEWSOLUTIONNAME")
                        LeResult = Execute(LoAction)

                        Select Case LeResult
                            'theres also saving of aMod solution file coz solution name causes changes in file names and paths. Also theres no "diskette icon" evidence of this change                      
                            Case GeActionResult.kkOk
                                Valid = True
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri premenovani projektu. Projektovy subor a adresar neboli vytvorene!"
                            Case GeActionResult.kkCancel
                                Valid = False
                                ErrorText = "ZRUSENIE_EDITACIE"
                                MoUcnPropertiesOfItemUC.tlTreeList.HideEditor()
                        End Select
                End Select
            Case "CLASSMODELRELATIONSHIPLINK"
                Select Case Row.GetValue("RowID")
                    Case 0
                        Dim LoMMLinkNode As ClsMMLinkNode = CType(Item, ClsMMLinkNode)
                        Dim LoMMDestinationTableNode As ClsMMTableNode = CType(LoMMLinkNode.Destination, ClsMMTableNode)

                        Select Case AmodVersion.UpdateRelationshipName(LoMMDestinationTableNode.AppTableName, CStr(Value))
                            Case GeActionResult.kkOk
                                Valid = True
                                LoMMLinkNode.Text = CStr(Value)
                            Case GeActionResult.kkError
                                Valid = False
                                ErrorText = "Chyba pri premenovani vztahu tried!"
                        End Select
                End Select
            Case "NOTELINK"
                Select Case Row.GetValue("RowID")
                    Case 0
                        Valid = True
                        Dim LoMMLinkNode As ClsMMLinkNode = CType(Item, ClsMMLinkNode)
                        LoMMLinkNode.Text = CStr(Value)
                        SetFileWasModified(True)
                End Select
            Case "USECASERELATIONSHIP"
                Select Case Row.GetValue("RowID")
                    Case 0
                        Valid = True
                        Dim LoMMLinkNode As ClsMMLinkNode = CType(Item, ClsMMLinkNode)
                        LoMMLinkNode.Text = CStr(Value)
                        SetFileWasModified(True)
                End Select
            Case "ACTOR"
                Select Case Row.GetValue("RowID")
                    Case 0
                        Valid = True
                        Dim LoMMActorNode As ClsMMActorNode = CType(Item, ClsMMActorNode)
                        Dim LoMMTextNode As ClsMMTextNode = CType(LoMMActorNode.SubordinateGroup.AttachedNodes(1), ClsMMTextNode)
                        LoMMTextNode.MMSetText(CStr(Value))
                        SetFileWasModified(True)
                End Select
            Case "ACTIVITY"
                Select Case Row.GetValue("RowID")
                    Case 0
                        Valid = True
                        Dim LoMMActivityNode As ClsMMActivityNode = CType(Item, ClsMMActivityNode)
                        LoMMActivityNode.Text = CStr(Value)
                        SetFileWasModified(True)
                End Select
            Case "SYSTEMBOUNDARY"
                Select Case Row.GetValue("RowID")
                    Case 0
                        Valid = True
                        Dim LoMMSystemBoundaryNode As ClsMMSystemBoundaryNode = CType(Item, ClsMMSystemBoundaryNode)
                        LoMMSystemBoundaryNode.Caption = CStr(Value)
                        SetFileWasModified(True)
                End Select

        End Select
        'Select Case Row.GetValue("PropertyID")
        '    Case GeTypeOfProperty.kkAppTableName
        '        Dim LoMMTableNode As ClsMMTableNode = CType(Item, ClsMMTableNode)
        '        Dim LsNewAppTableName As String = CStr(Value)
        '        Select Case AmodVersion.UpdateAppTableName(LoMMTableNode.AppTableName, LsNewAppTableName)
        '            Case GeActionResult.kkOk
        '                LoMMTableNode.AppTableName = LsNewAppTableName
        '                Valid = True
        '            Case GeActionResult.kkCancel
        '                Valid = False
        '                ErrorText = "Trieda s programatorskym nazvom """ & LsNewAppTableName & """ uz existuje!"
        '        End Select
        '    Case GeTypeOfProperty.kkHumanTableName
        '        Dim LoMMTableNode As ClsMMTableNode = CType(Item, ClsMMTableNode)
        '        Dim LsNewHumanTableName As String = CStr(Value)
        '        Select Case AmodVersion.UpdateHumanTableName(LoMMTableNode.AppTableName, LsNewHumanTableName)
        '            Case GeActionResult.kkOk
        '                LoMMTableNode.Caption = LsNewHumanTableName
        '                LoMMTableNode.MMResizeAllToFitTable()
        '                Valid = True
        '            Case GeActionResult.kkCancel
        '                Valid = False
        '                ErrorText = "Trieda s analytickym nazvom """ & LsNewHumanTableName & """ uz existuje!"
        '        End Select
        '    Case GeTypeOfProperty.kkUnitName
        '        Dim LoMMContainerNode As ClsMMContainerNode = CType(Item, ClsMMContainerNode)
        '        Dim LsNewUnitName As String = CStr(Value)
        '        Select Case AmodVersion.UpdateUnitName(LoMMContainerNode.UnitName, LsNewUnitName)
        '            Case GeActionResult.kkOk
        '                LoMMContainerNode.UnitName = LsNewUnitName
        '                Valid = True
        '            Case GeActionResult.kkCancel
        '                Valid = False
        '                ErrorText = "Unit s programatorskym nazvom """ & LsNewUnitName & """ uz existuje!"
        '        End Select
        '    Case GeTypeOfProperty.kkHumanUnitName
        '        Dim LoMMContainerNode As ClsMMContainerNode = CType(Item, ClsMMContainerNode)
        '        Dim LsNewHumanUnitName As String = CStr(Value)
        '        Select Case AmodVersion.UpdateHumanUnitName(LoMMContainerNode.UnitName, LsNewHumanUnitName)
        '            Case GeActionResult.kkOk
        '                LoMMContainerNode.Caption = LsNewHumanUnitName
        '                LoMMContainerNode.MMResizeAllToFitContainer()
        '                Valid = True
        '            Case GeActionResult.kkCancel
        '                Valid = False
        '                ErrorText = "Unit s analytickym nazvom """ & LsNewHumanUnitName & """ uz existuje!"
        '        End Select
        '    Case GeTypeOfProperty.kkModuleName
        '        Valid = False
        '        ErrorText = "Zmena programatorskeho nazvu modulu zatial nepodporovana!"
        '    Case GeTypeOfProperty.kkHumanModuleName
        '        Valid = False
        '        ErrorText = "Zmena analytickeho nazvu modulu zatial nepodporovana!"
        '    Case GeTypeOfProperty.kkVersionModuleName
        '        Dim LoUcnDiagramCanvasBase As UcnDiagramCanvasBase = CType(Item, UcnDiagramCanvasBase)
        '        Dim LsNewVersionModuleName As String = CStr(Value)
        '        Select Case MoDSaModFile.UpdateVersionModuleName(MoAmodVersion.GetVersionVID, LsNewVersionModuleName)
        '            'theres also saving of aMod file coz VersionModuleName was changed in aMod file DS and not in DsAModOneVersion DS, so theres no "diskette icon" evidence of this change                      
        '            Case GeActionResult.kkOk
        '                Valid = True
        '            Case GeActionResult.kkCancel
        '                Valid = False
        '        End Select
        '    Case GeTypeOfProperty.kkHumanVersionModuleName
        '        Dim LoUcnDiagramCanvasBase As UcnDiagramCanvasBase = CType(Item, UcnDiagramCanvasBase)
        '        Dim LsNewHumanVersionModuleName As String = CStr(Value)
        '        Select Case MoDSaModFile.UpdateHumanVersionModuleName(MoAmodVersion.GetVersionVID, LsNewHumanVersionModuleName)
        '            'theres also saving of aMod file coz VersionModuleName was changed in aMod file DS and not in DsAModOneVersion DS, so theres no "diskette icon" evidence of this change                      
        '            Case GeActionResult.kkOk
        '                Valid = True
        '            Case GeActionResult.kkCancel
        '                Valid = False
        '        End Select
        '    Case GeTypeOfProperty.kkAmodSolutionName
        '        Valid = False
        '        ErrorText = "Zmena nazvu aMod projektu zatial nepodporovana!"
        '    Case GeTypeOfProperty.kkLinkName
        '        Valid = True
        '        Dim LoMMLinkNode As ClsMMLinkNode = CType(Item, ClsMMLinkNode)
        '        LoMMLinkNode.Text = CStr(Value)
        'End Select
    End Sub
    Private Sub MoUcnPropertiesOfItemUC_MMInvalidValueException(ByVal e As DevExpress.XtraEditors.Controls.InvalidValueExceptionEventArgs) Handles MoUcnPropertiesOfItemUC.MMInvalidValueException
        If e.ErrorText = "ZRUSENIE_EDITACIE" Then
            e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.Ignore
        Else
            e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.DisplayError
        End If
    End Sub
#End Region
#Region "MoUcnPropertiesOfTableRowsUC - Events handler"
    'accepting changes after editing properties of table rows
    Private Sub MoUcnPropertiesOfTableRowsUC_MMValueChanged(ByVal Column As DevExpress.XtraGrid.Columns.GridColumn, ByVal NewValue As Object, ByVal OldValue As Object) Handles MoUcnPropertiesOfTableRowsUC.MMValueChanged
        Try
            SetFileWasModified(True)

            Select Case Column.FieldName
                Case "ColumnName", "ResValue", "DataType", "_a_UsedInView"
                    Dim LoMMTableNode As ClsMMTableNode = CType(Me.fcDiagram.ActiveItem, ClsMMTableNode)
                    LoMMTableNode.MMRebuildTable(AmodVersion.GetDataTableAllRowsSortedByPosition(LoMMTableNode.AppTableName))

                    Select Case Column.FieldName
                        Case "DataType"
                            'change decimals after column type was changed
                            'if "DataType" is decimal --> no control, otherwise (text, integer etc) set to 0
                            Dim LiActualDecimals As Integer = MoUcnPropertiesOfTableRowsUC.CardView.GetRowCellValue(MoUcnPropertiesOfTableRowsUC.CardView.FocusedRowHandle, KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.Decimals)
                            If NewValue <> KrosLib.Data.eDataType.Decimal AndAlso LiActualDecimals <> 0 Then
                                MoUcnPropertiesOfTableRowsUC.CardView.SetRowCellValue(MoUcnPropertiesOfTableRowsUC.CardView.FocusedRowHandle, KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.Decimals, 0)
                            End If
                        Case "ColumnName"
                            'refreshes panel in main tab with table columns info joined to module
                            If IsThisTheLastVersion Then RefreshTableColumnsJoinedToModule(DSaModFile.GetLastVersionModuleName, MoAmodVersion.GetTableListRowByAppTableName(LoMMTableNode.AppTableName)(AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName), LoMMTableNode.AppTableName, OldValue)
                        Case "ResValue"
                            'refreshes panel in main tab with table columns info joined to module
                            Dim LsColumnName As String = MoUcnPropertiesOfTableRowsUC.CardView.GetRowCellValue(MoUcnPropertiesOfTableRowsUC.CardView.FocusedRowHandle, KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.ColumnName)
                            If IsThisTheLastVersion Then RefreshTableColumnsJoinedToModule(DSaModFile.GetLastVersionModuleName, MoAmodVersion.GetTableListRowByAppTableName(LoMMTableNode.AppTableName)(AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName), LoMMTableNode.AppTableName, LsColumnName)
                    End Select

                Case "JoinModuleID"
                    If IsThisTheLastVersion Then
                        'refreshes panel in main tab with table columns info joined to module
                        Dim LoActiveItem As DiagramItem = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram.ActiveItem
                        If LoActiveItem.GetType.Name = "ClsMMModuleNode" Then
                            Dim LoMMModuleNode As ClsMMModuleNode = CType(LoActiveItem, ClsMMModuleNode)
                            If LoMMModuleNode.ModuleName = NewValue Or LoMMModuleNode.ModuleName = OldValue Then
                                MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshSelectedItemProperties(LoMMModuleNode, False)
                            End If
                        End If

                        'saving after new joined module was assigned
                        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModSaveVersionAndFile)
                        Execute(LoAction)
                    End If
                Case "_a_ComponentType"
                    Select Case NewValue
                        Case 4
                            'DateTime
                            MoUcnPropertiesOfTableRowsUC.CardView.SetRowCellValue(MoUcnPropertiesOfTableRowsUC.CardView.FocusedRowHandle, KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.DataType, KrosLib.Data.eDataType.DateTime)
                        Case 7
                            'Memo
                            MoUcnPropertiesOfTableRowsUC.CardView.SetRowCellValue(MoUcnPropertiesOfTableRowsUC.CardView.FocusedRowHandle, KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.DataType, KrosLib.Data.eDataType.Memo)
                    End Select
            End Select
        Catch ex As Exception

        End Try
    End Sub
    'validating new value
    Private Sub MoUcnPropertiesOfTableRowsUC_MMValueValidating(ByVal Item As Object, ByVal Column As DevExpress.XtraGrid.Columns.GridColumn, ByRef Value As Object, ByRef Valid As Boolean, ByRef ErrorText As String, ByVal OldValue As Object) Handles MoUcnPropertiesOfTableRowsUC.MMValueValidating
        Select Case Column.FieldName
            Case "ColumnName"
                Dim LeResult As GeActionResult = GeActionResult.kkOk
                Dim LoMMTableNode As ClsMMTableNode = CType(Item, ClsMMTableNode)

                Dim LsOldColumnName As String = CStr(OldValue)
                Dim LsNewColumnName As String = FormatProgrammaticTableAndTableRowName(CStr(Value))

                If LsNewColumnName <> "" Then
                    LeResult = AmodVersion.UpdateTableColumnName(LoMMTableNode.AppTableName, LsOldColumnName, LsNewColumnName)
                Else
                    LeResult = GeActionResult.kkError
                    MessageBox.Show("Programatorsky nazov polozky triedy nesmie byt prazdny retazec!" & vbNewLine & vbNewLine & "Programatorsky nazov moze obsahovat iba velke pismena abecedy, znak ""_"" a cisla nie na zaciatku nazvu. Po prisposobeni Vami zadaneho nazvu je vsak vysledkom prazdny retazec.", "Neprijatelny programatorsky nazov polozky triedy", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                End If

                Select Case LeResult
                    Case GeActionResult.kkOk
                        Value = LsNewColumnName
                        Valid = True
                    Case GeActionResult.kkError
                        Valid = False
                        ErrorText = "Chyba pri zmene programatorskeho nazvu polozky triedy!"
                    Case GeActionResult.kkCancel
                        Valid = False
                        ErrorText = "Polozka s programatorskym nazvom """ & LsNewColumnName & """ uz existuje!"
                End Select
            Case "ResValue"
                Dim LeResult As GeActionResult = GeActionResult.kkOk
                Dim LoMMTableNode As ClsMMTableNode = CType(Item, ClsMMTableNode)
                Dim LsNewHumanColumnName As String = CStr(Value)

                LeResult = AmodVersion.UpdateTableHumanColumnName(LoMMTableNode.AppTableName, CStr(OldValue), LsNewHumanColumnName)

                Select Case LeResult
                    Case GeActionResult.kkOk
                        Value = LsNewHumanColumnName
                        Valid = True
                    Case GeActionResult.kkError
                        Valid = False
                        ErrorText = "Chyba pri zmene analytickeho nazvu polozky triedy!"
                    Case GeActionResult.kkCancel
                        Valid = False
                        ErrorText = "Polozka s analytickym nazvom """ & LsNewHumanColumnName & """ uz existuje!"
                End Select
            Case "JoinModuleID"
                Dim LeResult As GeActionResult = GeActionResult.kkCancel
                Dim LoAction As ClsAction = New ClsAction(GeAction.kkNoAction)

                'open last version of joined module
                Dim LsJoinedModuleName As String = CStr(Value)
                Dim LoJoinedDsAModOneVersion As ClsDsAModOneVersion = Nothing
                Dim LbCloseVersion As Boolean = False
                If LsJoinedModuleName <> "" Then
                    'change joined module
                    Dim LsJoinedAmodFilePath As String = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAmodFilePath(LsJoinedModuleName)
                    Dim LoJoinedAmodFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsJoinedAmodFilePath, True)
                    If LoJoinedAmodFile Is Nothing Then
                        'aMod file is not opened - open it
                        LeResult = QuickOpenAmodFile(LsJoinedAmodFilePath, LoJoinedAmodFile)
                    End If

                    If LoJoinedAmodFile IsNot Nothing Then
                        'open version
                        LoJoinedDsAModOneVersion = LoJoinedAmodFile.OpenedEditableVersions.GetItem(LoJoinedAmodFile.Dat.GetLastVersion, True)
                        If LoJoinedDsAModOneVersion Is Nothing Then
                            LoJoinedDsAModOneVersion = LoJoinedAmodFile.OpenVersion(LoJoinedAmodFile.Dat.GetLastVersion, False)
                            LbCloseVersion = True
                        End If
                    End If

                    If LoJoinedDsAModOneVersion IsNot Nothing Then
                        If LoJoinedDsAModOneVersion.DSaModVersion.MainTableName <> "" Then
                            'add joined modules links to main tab only when Im working with last version
                            If IsThisTheLastVersion Then
                                If Value <> "" Then
                                    If OldValue <> Value Then
                                        'adding new joined module
                                        LoAction.Action = GeAction.kkaModSolutionAddJoinedModuleOfTableColumn
                                        LoAction.SetData(MoDSaModFile.GetLastVersionModuleName, "ORIGINALMODULENAME")
                                        LoAction.SetData(Value, "NEWJOINEDMODULENAME")
                                        LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(LoAction)

                                        If LeResult = GeActionResult.kkOk AndAlso OldValue <> "" Then
                                            'changing joined module - new joined module was changed, also remove old one
                                            LoAction.Action = GeAction.kkaModSolutionRemoveJoinedModuleOfTableColumn
                                            LoAction.SetData(MoDSaModFile.GetLastVersionModuleName, "ORIGINALMODULENAME")
                                            LoAction.SetData(OldValue, "JOINEDMODULENAMEFORREMOVE")
                                            LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(LoAction)
                                        End If
                                        LeResult = GeActionResult.kkOk
                                    End If
                                Else
                                    If OldValue <> "" Then
                                        'removing joined module
                                        LoAction.Action = GeAction.kkaModSolutionRemoveJoinedModuleOfTableColumn
                                        LoAction.SetData(MoDSaModFile.GetLastVersionModuleName, "ORIGINALMODULENAME")
                                        LoAction.SetData(OldValue, "JOINEDMODULENAMEFORREMOVE")
                                        LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(LoAction)
                                    End If
                                End If
                            End If

                            '########################################
                            If AmodVersion.DSaModVersion.SetJoinedModule(LsJoinedModuleName, MoUcnPropertiesOfTableRowsUC.CardView.GetFocusedDataRow, LoJoinedDsAModOneVersion.DSaModVersion) = True Then
                                LeResult = GeActionResult.kkOk
                            Else
                                LeResult = GeActionResult.kkError
                            End If
                            '########################################

                            ''saving joined module version and file
                            'LoJoinedAmodFile.SaveVersion(LoJoinedAmodFile.Dat.GetLastVersion)
                            'LoJoinedAmodFile.SaveFile()
                        Else
                            MessageBox.Show("Navazovany modul musi obsahovat aspon jednu tabulku. Otvorte jeho poslednu verziu a pridajte ju.", "Ziadna tabulka v navazovanom module", MessageBoxButtons.OK, MessageBoxIcon.Information)
                            LeResult = GeActionResult.kkError
                        End If
                    Else
                        MessageBox.Show("Nepodarilo sa otvorit verziu pre zmenu nazvu naviazaneho modulu!", "Chyba pri otvarani verzie", MessageBoxButtons.OK, MessageBoxIcon.Error)
                        LeResult = GeActionResult.kkError
                    End If

                    'close version if it was opened just for this purpose
                    If LbCloseVersion Then
                        LoJoinedAmodFile.CloseVersion(LoJoinedDsAModOneVersion)
                    End If
                Else
                    If OldValue <> "" Then 'this condition is for situation when joined module value was changed from "" to "" - there are some special situation :-)
                        'remove joined module
                        If AmodVersion.DSaModVersion.SetJoinedModule(LsJoinedModuleName, MoUcnPropertiesOfTableRowsUC.CardView.GetFocusedDataRow, Nothing) = True Then
                            If IsThisTheLastVersion Then
                                LoAction.Action = GeAction.kkaModSolutionRemoveJoinedModuleOfTableColumn
                                LoAction.SetData(MoDSaModFile.GetLastVersionModuleName, "ORIGINALMODULENAME")
                                LoAction.SetData(OldValue, "JOINEDMODULENAMEFORREMOVE")
                                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(LoAction)
                            End If
                        Else
                            LeResult = GeActionResult.kkError
                        End If
                    End If
                End If

                Select Case LeResult
                    Case GeActionResult.kkOk
                        Valid = True
                    Case GeActionResult.kkError
                        Valid = False
                        ErrorText = "Chyba pri zmene napojeneho modulu stlpca!"
                    Case GeActionResult.kkCancel
                        Valid = False
                        ErrorText = "ZRUSENIE_EDITACIE"
                        MoUcnPropertiesOfTableRowsUC.CardView.HideEditor()
                End Select
            Case Else
                Valid = True
        End Select
    End Sub
    Private Sub MoUcnPropertiesOfTableRowsUC_MMInvalidValueException(ByVal e As DevExpress.XtraEditors.Controls.InvalidValueExceptionEventArgs) Handles MoUcnPropertiesOfTableRowsUC.MMInvalidValueException
        If e.ErrorText = "ZRUSENIE_EDITACIE" Then
            e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.Ignore
        Else
            e.ExceptionMode = DevExpress.XtraEditors.Controls.ExceptionMode.DisplayError
        End If
    End Sub
    'adding row to table
    Private Sub MoUcnPropertiesOfTableRowsUC_MMAddItem(ByRef Item As DiagramItem, ByVal NewRowPosition As Integer, ByVal NewDataNavigatorPosition As Integer) Handles MoUcnPropertiesOfTableRowsUC.MMAddItem
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkAddColumnToTable)
        LoAction.SetData(Item, "TABLE")
        LoAction.SetData("POLOZKA", "ORIGINALCOLUMNNAME")
        LoAction.SetData("Polozka", "ORIGINALHUMANCOLUMNNAME")
        LoAction.SetData(NewRowPosition, "POSITIONOFCOLUMN")
        If Execute(LoAction) = GeActionResult.kkOk Then
            RefreshSelectedItemProperties(Item, True) 'MoAmodFile.GetNumberOfColumns(CType(Item, ClsMMTableNode).Caption) - 1)
        Else
            Debug.Print("CHYBA!!! - MoUcnPropertiesUC_MMAddItem")
        End If
    End Sub
    'removing row from table
    Private Sub MoUcnPropertiesOfTableRowsUC_MMRemoveItem(ByRef Item As DiagramItem, ByVal ColumnName As String, ByVal NewDataNavigatorPosition As Integer) Handles MoUcnPropertiesOfTableRowsUC.MMRemoveItem
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkRemoveColumnFromTable)
        LoAction.SetData(Item, "TABLE")
        LoAction.SetData(ColumnName, "COLUMNNAME")
        If Execute(LoAction) = GeActionResult.kkOk Then
            Dim LoMMTableNode As ClsMMTableNode = CType(Item, ClsMMTableNode)
            'last item was removed so change HighlightedRow property before rereshing item properties
            If LoMMTableNode.HighlightedRow > LoMMTableNode.Rows.Count - 1 Then LoMMTableNode.HighlightedRow = LoMMTableNode.Rows.Count - 1
            RefreshSelectedItemProperties(Item, True) 'MoAmodFile.GetNumberOfColumns(CType(Item, ClsMMTableNode).Caption) - 1)
        Else
            Debug.Print("CHYBA!!! - MoUcnPropertiesUC_MMRemoveItem")
        End If
    End Sub
    'moving table row up
    Private Sub MoUcnPropertiesOfTableRowsUC_MMMoveUp(ByRef Item As MindFusion.Diagramming.DiagramItem) Handles MoUcnPropertiesOfTableRowsUC.MMMoveUp
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModMoveUpColumnOfTable)
        LoAction.SetData(Item, "TABLE")
        LoAction.SetData(CType(Item, ClsMMTableNode).HighlightedRow, "ROWINDEX")
        If Execute(LoAction) = GeActionResult.kkOk Then
            CType(Item, ClsMMTableNode).HighlightedRow -= 1
            RefreshSelectedItemProperties(Item, False)
        End If
    End Sub
    'moving table row down
    Private Sub MoUcnPropertiesOfTableRowsUC_MMMoveDown(ByRef Item As MindFusion.Diagramming.DiagramItem) Handles MoUcnPropertiesOfTableRowsUC.MMMoveDown
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaMOdMoveDownColumnOfTable)
        LoAction.SetData(Item, "TABLE")
        LoAction.SetData(CType(Item, ClsMMTableNode).HighlightedRow, "ROWINDEX")
        If Execute(LoAction) = GeActionResult.kkOk Then
            CType(Item, ClsMMTableNode).HighlightedRow += 1
            RefreshSelectedItemProperties(Item, False)
        End If
    End Sub
    'changing actual selected row
    'field caption custom drawing
    Private Sub MoUcnPropertiesOfTableRowsUC_MMCustomDrawCardFieldCaption(ByVal e As DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs) Handles MoUcnPropertiesOfTableRowsUC.MMCustomDrawCardFieldCaption
        If MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab AndAlso fcDiagram.ActiveItem.GetType.Name = "ClsMMTableNode" Then
            Dim LoMMTableNode As ClsMMTableNode = CType(fcDiagram.ActiveItem, ClsMMTableNode)
            'there are change columns saved in tag of the first cell
            Dim LoChangedColumns As Collection = CType(LoMMTableNode(0, LoMMTableNode.HighlightedRow).Tag, Collection)
            'color row as changed
            If LoChangedColumns IsNot Nothing AndAlso LoChangedColumns.Contains(e.Column.FieldName) Then
                e.Appearance.BackColor = Color.Blue
                e.Appearance.ForeColor = Color.White
            End If
        End If
    End Sub
    'field value custom drawing
    Private Sub MoUcnPropertiesOfTableRowsUC_MMCustomDrawCardFieldValue(ByVal e As DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs) Handles MoUcnPropertiesOfTableRowsUC.MMCustomDrawCardFieldValue
        If MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab AndAlso fcDiagram.ActiveItem.GetType.Name = "ClsMMTableNode" Then
            Dim LoMMTableNode As ClsMMTableNode = CType(fcDiagram.ActiveItem, ClsMMTableNode)
            'there are change columns saved in tag of the first cell
            Dim LoChangedColumns As Collection = CType(LoMMTableNode(0, LoMMTableNode.HighlightedRow).Tag, Collection)
            'color row as changed
            If LoChangedColumns IsNot Nothing AndAlso LoChangedColumns.Contains(e.Column.FieldName) Then
                e.Appearance.BackColor = Color.Blue
                e.Appearance.ForeColor = Color.White
            End If
        End If
    End Sub
    'before activating an cell editor
    Private Sub MoUcnPropertiesOfTableRowsUC_MMShowingEditor(ByVal e As System.ComponentModel.CancelEventArgs) Handles MoUcnPropertiesOfTableRowsUC.MMShowingEditor
        e.Cancel = MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab Or ((MoUcnPropertiesOfTableRowsUC.CardView.FocusedColumn.FieldName = "ResValue" Or MoUcnPropertiesOfTableRowsUC.CardView.FocusedColumn.FieldName = "ColumnName") AndAlso IsTableColumnPKorFK(fcDiagram.ActiveItem, CType(fcDiagram.ActiveItem, ClsMMTableNode).HighlightedRow))
    End Sub
    Private Sub MoUcnPropertiesOfTableRowsUC_MMPositionOfNavigatorChanged(ByVal Position As Integer) Handles MoUcnPropertiesOfTableRowsUC.MMPositionOfNavigatorChanged
        If Me.fcDiagram.ActiveItem IsNot Nothing Then
            If Me.fcDiagram.ActiveItem.GetType.Name = "ClsMMTableNode" Then
                Dim LoMMTableNode As ClsMMTableNode = CType(Me.fcDiagram.ActiveItem, ClsMMTableNode)
                LoMMTableNode.HighlightedRow = Position
            End If
        End If
    End Sub
#End Region
#Region "MoUcnRTFeditorUC - Events handler"
    'text is changing 
    Private Sub MoUcnRTFeditorUC_MMTextChanging() Handles MoUcnRTFeditorUC.MMTextChanging
        If Not MoUcnRTFeditorUC.InitOfText Then
            Dim LoItem As DiagramItem = Me.fcDiagram.ActiveItem
            If LoItem IsNot Nothing Then
                Select Case LoItem.GetType.Name
                    Case "ClsMMNoteNode"
                        Dim LoMMNoteNode As ClsMMNoteNode = CType(LoItem, ClsMMNoteNode)
                        LoMMNoteNode.Text = MoUcnRTFeditorUC.ResultActualPlainText
                        SetFileWasModified(True)
                End Select
            End If
        End If
    End Sub
    'text changes were confirmed
    Private Sub MoUcnRTFeditorUC_MMValueChangesConfirmed(ByVal NewValue As String) Handles MoUcnRTFeditorUC.MMValueChangesConfirmed
        If Not MoUcnRTFeditorUC.InitOfText Then
            Dim LoItem As DiagramItem = Me.fcDiagram.ActiveItem
            If LoItem IsNot Nothing Then
                Select Case LoItem.GetType.Name
                    Case "ClsMMContainerNode"
                        Dim LoMMContainerNode As ClsMMContainerNode = CType(LoItem, ClsMMContainerNode)
                        Dim LsOldRTFdescription As String = AmodVersion.GetRTFdescriptionOfUnit(LoMMContainerNode.UnitName)
                        If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                            AmodVersion.UpdateRTFDescriptionOfUnit(LoMMContainerNode.UnitName, MoUcnRTFeditorUC.ResultRTFText)
                            LoMMContainerNode.HasRTFnote = MoUcnRTFeditorUC.ResultPlainText <> ""
                            SetFileWasModified(True)
                        End If
                    Case "ClsMMTableNode"
                        Dim LoMMTableNode As ClsMMTableNode = CType(LoItem, ClsMMTableNode)
                        If LoMMTableNode.HighlightedRow = -1 Then
                            'table is selected 
                            Dim LsOldRTFdescription As String = AmodVersion.GetRTFdescriptionOfTable(LoMMTableNode.AppTableName)
                            If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                                AmodVersion.UpdateRTFDescriptionOfTable(LoMMTableNode.AppTableName, MoUcnRTFeditorUC.ResultRTFText)
                                LoMMTableNode.HasRTFnote = MoUcnRTFeditorUC.ResultPlainText <> ""
                                SetFileWasModified(True)
                            End If
                        Else
                            'table cell is selected 
                            Dim LsOldRTFdescription As String = AmodVersion.GetRTFdescriptionOfTableRow(LoMMTableNode.AppTableName, LoMMTableNode.MMGetColumnNameByRowIndex(LoMMTableNode.HighlightedRow))
                            If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                                AmodVersion.UpdateRTFDescriptionOfTableRow(LoMMTableNode.AppTableName, LoMMTableNode.MMGetColumnNameByRowIndex(LoMMTableNode.HighlightedRow), MoUcnRTFeditorUC.ResultRTFText)
                                LoMMTableNode.MMSetRTFnoteRowIndicator(LoMMTableNode.HighlightedRow, MoUcnRTFeditorUC.ResultPlainText <> "")
                                SetFileWasModified(True)
                            End If
                        End If
                    Case "ClsMMLinkNode"
                        Dim LoMMLinkNode As ClsMMLinkNode = CType(LoItem, ClsMMLinkNode)
                        Select Case LoMMLinkNode.MMTypeOfLink
                            Case GeTypeOfLink.kkClassDiagramRelationship
                                Select Case MoTabPage.TypeOfTab
                                    Case GeTypeOfTab.kkClassDiagramTab
                                        Dim LoDestinationMMTableNode As ClsMMTableNode = CType(LoMMLinkNode.Destination, ClsMMTableNode)
                                        Dim LsOldRTFdescription As String = AmodVersion.GetRTFdescriptionOfRelationship(LoDestinationMMTableNode.AppTableName)
                                        If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                                            AmodVersion.UpdateRTFDescriptionOfRelationship(LoDestinationMMTableNode.AppTableName, MoUcnRTFeditorUC.ResultRTFText)
                                            SetFileWasModified(True)
                                        End If
                                    Case GeTypeOfTab.kkVersionComparisonTab
                                        'do nothing
                                End Select
                            Case GeTypeOfLink.kkUseCaseRelationship, GeTypeOfLink.kkNote
                                Dim LsOldRTFdescription As String = CStr(LoMMLinkNode.Tag)
                                If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                                    LoMMLinkNode.Tag = MoUcnRTFeditorUC.ResultRTFText
                                    SetFileWasModified(True)
                                End If
                        End Select
                    Case "ClsMMModuleNode"
                        Dim LoMMModuleNode As ClsMMModuleNode = CType(LoItem, ClsMMModuleNode)
                        Dim LsOldRTFdescription As String = MoDSaModSolutionFile.GetRTFdescriptionOfModule(LoMMModuleNode.ModuleName)
                        If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                            MoDSaModSolutionFile.UpdateRTFdescriptionOfModule(LoMMModuleNode.ModuleName, MoUcnRTFeditorUC.ResultRTFText)
                            LoMMModuleNode.HasRTFnote = MoUcnRTFeditorUC.ResultPlainText <> ""
                            SetFileWasModified(True)
                        End If
                    Case "ClsMMNoteNode"
                        Dim LoMMNoteNode As ClsMMNoteNode = CType(LoItem, ClsMMNoteNode)
                        If MoTabPage.TypeOfTab = GeTypeOfTab.kkClassDiagramTab Then AmodVersion.UpdateNoteText(LoMMNoteNode.ID, MoUcnRTFeditorUC.ResultPlainText)
                        SetFileWasModified(True)
                    Case "ClsMMActorNode"
                        Dim LoMMActorNode As ClsMMActorNode = CType(LoItem, ClsMMActorNode)
                        Dim LsOldRTFdescription As String = CStr(LoMMActorNode.Tag)
                        If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                            LoMMActorNode.Tag = MoUcnRTFeditorUC.ResultRTFText
                            LoMMActorNode.HasRTFnote = MoUcnRTFeditorUC.ResultPlainText <> ""
                            SetFileWasModified(True)
                        End If
                    Case "ClsMMActivityNode"
                        Dim LoMMActivityNode As ClsMMActivityNode = CType(LoItem, ClsMMActivityNode)
                        Dim LsOldRTFdescription As String = CStr(LoMMActivityNode.Tag)
                        If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                            LoMMActivityNode.Tag = MoUcnRTFeditorUC.ResultRTFText
                            LoMMActivityNode.HasRTFnote = MoUcnRTFeditorUC.ResultPlainText <> ""
                            SetFileWasModified(True)
                        End If
                    Case "ClsMMSystemBoundaryNode"
                        Dim LoMMSystemBoundaryNode As ClsMMSystemBoundaryNode = CType(LoItem, ClsMMSystemBoundaryNode)
                        Dim LsOldRTFdescription As String = CStr(LoMMSystemBoundaryNode.Tag)
                        If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                            LoMMSystemBoundaryNode.Tag = MoUcnRTFeditorUC.ResultRTFText
                            LoMMSystemBoundaryNode.HasRTFnote = MoUcnRTFeditorUC.ResultPlainText <> ""
                            SetFileWasModified(True)
                        End If
                    Case Else
                        Debug.Print("CHYBA!!! - UcnRTFeditorUC_ValueChangesConfirmed")
                End Select
            Else
                Select Case MoTabPage.TypeOfTab
                    Case GeTypeOfTab.kkClassDiagramTab
                        If MoDSaModFile IsNot Nothing AndAlso MoAmodVersion IsNot Nothing Then
                            'refresh RTF note
                            Dim LsOldRTFdescription As String = MoDSaModFile.GetRTFdescriptionOfVersion(AmodVersion.GetVersionVID)
                            If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                                MoDSaModFile.UpdateRTFDescriptionOfVersion(AmodVersion.GetVersionVID, MoUcnRTFeditorUC.ResultRTFText)
                                SetFileWasModified(True)
                            End If
                        End If
                    Case GeTypeOfTab.kkMainTab
                        If MoDSaModSolutionFile IsNot Nothing Then
                            'refresh RTF note
                            Dim LsOldRTFdescription As String = MoDSaModSolutionFile.GetRTFdescriptionOfSolution
                            If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                                MoDSaModSolutionFile.UpdateRTFdescriptionOfSolution(MoUcnRTFeditorUC.ResultRTFText)
                                SetFileWasModified(True)
                            End If
                        End If
                    Case GeTypeOfTab.kkUseCaseTab
                        If MoDSaModFile IsNot Nothing Then
                            'refresh RTF note
                            Dim LsOldRTFdescription As String = CStr(fcDiagram.Tag)
                            If LsOldRTFdescription <> MoUcnRTFeditorUC.ResultRTFText AndAlso Not (LsOldRTFdescription = "" AndAlso MoUcnRTFeditorUC.ResultPlainText = "") Then
                                fcDiagram.Tag = MoUcnRTFeditorUC.ResultRTFText
                                SetFileWasModified(True)
                            End If
                        End If
                End Select
            End If
        End If
    End Sub
#End Region
#Region "MoUcnRelationsUC - Events handler"
    Private Sub MoUcnRelationsUC_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MoUcnRelationsUC.MouseDown
        'canceling secondary operation
        If Not MoHand.IsChangingSecondaryOperation Then MoHand.SecondaryOperation = GeSecondaryOperationOfHand.kkIdle
    End Sub
    'setting new type of link of hand
    Private Sub MoUcnRelationsUC_MMSelectedIndexChanged() Handles MoUcnRelationsUC.MMSelectedIndexChanged
        'checking semaphore
        If Not MoHand.IsChangingTypeOfLink Then
            MoHand.TypeOfLink = MoUcnRelationsUC.GetDataOfSelectedItem
            '' ''Select Case ilbRelationships.SelectedIndex
            '' ''    Case 0
            '' ''        MoHand.TypeOfLink = KrosLib.Data.eRelationType.OneToZeroOrOne  'kkRelationTypes.kk_1_01
            '' ''    Case 1
            '' ''        MoHand.TypeOfLink = KrosLib.Data.eRelationType.OneToOne  'kkRelationTypes.kk_1_1
            '' ''    Case 2
            '' ''        MoHand.TypeOfLink = KrosLib.Data.eRelationType.OneToOneOrMore  'kkRelationTypes.kk_1_1n
            '' ''    Case 3
            '' ''        MoHand.TypeOfLink = KrosLib.Data.eRelationType.OneToMany  'kkRelationTypes.kk_1_n
            '' ''    Case Else
            '' ''        Debug.Print("CHYBA!!! - ilbRelationships_SelectedIndexChanged")
            '' ''End Select
            'MoHand.TypeOfLink = ilbRelationships.SelectedIndex
            ' ''Select Case ilbRelationships.SelectedIndex
            ' ''    Case 0
            ' ''        MoHand.TypeOfLink = GeTypeOfLink.kkLink1a01
            ' ''    Case 1
            ' ''        MoHand.TypeOfLink = GeTypeOfLink.kkLink1a1N
            ' ''    Case 2
            ' ''        MoHand.TypeOfLink = GeTypeOfLink.kkLink1aN
            ' ''End Select
        End If
    End Sub
#End Region
#Region "MoUcnJoinedModulesInfoUC - Events handler"
    Private Sub MoUcnJoinedModulesInfoUC_MMSettings() Handles MoUcnJoinedModulesInfoUC.MMSettings
        MoUcnJoinedModulesInfoUC.tlTreeList.OptionsView.ShowIndicator = False
        MoUcnJoinedModulesInfoUC.tlTreeList.OptionsSelection.EnableAppearanceFocusedCell = False
        MoUcnJoinedModulesInfoUC.tlTreeList.OptionsSelection.EnableAppearanceFocusedRow = True
        MoUcnJoinedModulesInfoUC.tlTreeList.OptionsView.ShowColumns = True
        MoUcnJoinedModulesInfoUC.tlTreeList.OptionsView.ShowCheckBoxes = False
        MoUcnJoinedModulesInfoUC.tlTreeList.OptionsView.ShowRoot = False
    End Sub
    Private Sub MoUcnJoinedModulesInfoUC_MMCreateDataSource() Handles MoUcnJoinedModulesInfoUC.MMCreateDataSource
        'ATTENTION: keep the same order here and during adding rows to DataSource
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(0).FieldName = "RowID"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(1).FieldName = "ParentRowID"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(2).FieldName = "Enabled"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(3).FieldName = "Selected"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(4).FieldName = "ModuleName"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(5).FieldName = "HumanModuleName"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(6).FieldName = "UnitName"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(7).FieldName = "HumanUnitName"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(8).FieldName = "TableName"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(9).FieldName = "HumanTableName"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(10).FieldName = "ColumnName"
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns.Add()
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(11).FieldName = "HumanColumnName"

        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(4).VisibleIndex = 1
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(5).VisibleIndex = 2
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(6).VisibleIndex = 3
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(7).VisibleIndex = 4
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(8).VisibleIndex = 5
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(9).VisibleIndex = 6
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(10).VisibleIndex = 7
        MoUcnJoinedModulesInfoUC.tlTreeList.Columns(11).VisibleIndex = 8

        '"RowID" AND "ParentRowID" ARE UNIQUE IDENTIFIERS FOR TREELIST AND THESE COLUMNS ARE INVISIBLE IN TREELIST COZ THEY ARE SET TO PROPERTIES KeyFieldName and ParentFieldName PROPERTIES OF TREELIST
    End Sub
    Private Sub MoUcnJoinedModulesInfoUC_MMColumnProperties(ByRef Column As DevExpress.XtraTreeList.Columns.TreeListColumn) Handles MoUcnJoinedModulesInfoUC.MMColumnProperties
        Try
            Select Case Column.FieldName
                Case "ModuleName"
                    Column.Caption = "Progr. nazov modulu"
                    Column.OptionsColumn.AllowEdit = False
                Case "HumanModuleName"
                    Column.Caption = "Analyt. nazov modulu"
                    Column.OptionsColumn.AllowEdit = False
                    Column.SortOrder = SortOrder.Ascending
                Case "UnitName"
                    Column.Caption = "Progr. nazov formulara"
                    Column.OptionsColumn.AllowEdit = False
                Case "HumanUnitName"
                    Column.Caption = "Analyt. nazov formulara"
                    Column.OptionsColumn.AllowEdit = False
                Case "TableName"
                    Column.Caption = "Progr. nazov triedy"
                    Column.OptionsColumn.AllowEdit = False
                Case "HumanTableName"
                    Column.Caption = "Analyt. nazov triedy"
                    Column.OptionsColumn.AllowEdit = False
                Case "ColumnName"
                    Column.Caption = "Progr. nazov polozky"
                    Column.OptionsColumn.AllowEdit = False
                Case "HumanColumnName"
                    Column.Caption = "Analyt. nazov polozky"
                    Column.OptionsColumn.AllowEdit = False
                Case Else
                    'Column.Caption will be the same like Column.FieldName
                    Column.VisibleIndex = -1
                    Column.OptionsColumn.AllowEdit = False
            End Select
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    Private Sub MoUcnJoinedModulesInfoUC_MMFillDataSource(ByVal Item As Object, ByRef DataSource As Microsoft.VisualBasic.Collection) Handles MoUcnJoinedModulesInfoUC.MMFillDataSource
        If Item IsNot Nothing Then
            Dim LoJoinedTableColumnsJoinedToModule As Collection = New Collection
            Dim LsJoinedModuleName As String = ""

            Select Case Item.GetType.Name
                Case "ClsMMLinkNode"
                    Dim LoLink As ClsMMLinkNode = CType(Item, ClsMMLinkNode)
                    Dim LoJoinedMMModuleNode As ClsMMModuleNode = CType(LoLink.Destination, ClsMMModuleNode)
                    Dim LoChildMMModuleNode As ClsMMModuleNode = CType(LoLink.Origin, ClsMMModuleNode)
                    Dim LsChildModuleName As String = LoChildMMModuleNode.ModuleName
                    Dim LsChildHumanModuleName As String = LoChildMMModuleNode.Text
                    LsJoinedModuleName = LoJoinedMMModuleNode.ModuleName
                    GetTableColumnsJoinedToModuleFromModule(LsJoinedModuleName, LsChildModuleName, LsChildHumanModuleName, LoJoinedTableColumnsJoinedToModule)
                Case "ClsMMModuleNode"
                    Dim LoJoinedMMModuleNode As ClsMMModuleNode = CType(Item, ClsMMModuleNode)
                    LsJoinedModuleName = LoJoinedMMModuleNode.ModuleName
                    LoJoinedTableColumnsJoinedToModule = GetTableColumnsJoinedToModuleFromAllModules(LsJoinedModuleName)
            End Select
            Dim LiI As Integer = 0
            For Each LoItem As String() In LoJoinedTableColumnsJoinedToModule
                LiI = LiI + 1
                DataSource.Add(New ClsUcnGridUnboundItemJoinedModulesInfo(0 + LiI, -1, True, False, LoItem(0), LoItem(1), LoItem(2), LoItem(3), LoItem(4), LoItem(5), LoItem(6), LoItem(7)))
            Next
        End If
    End Sub
    Private Sub MoUcnJoinedModulesInfoUC_MMRowDoubleClicked(ByVal Row As DevExpress.XtraTreeList.Nodes.TreeListNode) Handles MoUcnJoinedModulesInfoUC.MMRowDoubleClicked
        Try
            Dim LsModuleName As String = Row("ModuleName")
            Dim LsTableName As String = Row("TableName")
            Dim LsColumnName As String = Row("ColumnName")

            'open version
            Dim LeResult As GeActionResult = GeActionResult.kkOk
            Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModTryToOpenVersions)
            Dim LoVersions As Collection = New Collection
            LoVersions.Add(-1)
            '-1 = last version

            LoAction.SetData(LoVersions, "VERSIONS")
            'LoAction.SetData(LsModuleName, "MODULENAME")
            LoAction.SetData(MoDSaModSolutionFile.GetAmodFilePath(LsModuleName), "PATHTOFILE")
            LeResult = Execute(LoAction)

            'select table and its row
            If LeResult = GeActionResult.kkOk Then
                Dim LoTab As ClsUcnTabPage = LoAction.GetData("TABPAGE")
                Dim LoMMTableNode As ClsMMTableNode = GetTableFromDiagramByTableName(LsTableName, LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram)
                LoMMTableNode.HighlightedRow = LoMMTableNode.MMGeRowIndexByColumnName(LsColumnName)
                LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshSelectedItemProperties(LoMMTableNode, False)
            End If
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
#End Region
#Region "MoUcnVersionsChangesUC - Events handler"
    Private Sub MoUcnVersionsChangesUC_MMSettings() Handles MoUcnVersionsChangesUC.MMSettings
        MoUcnVersionsChangesUC.tlTreeList.OptionsView.ShowIndicator = False
        MoUcnVersionsChangesUC.tlTreeList.OptionsSelection.EnableAppearanceFocusedCell = False
        MoUcnVersionsChangesUC.tlTreeList.OptionsSelection.EnableAppearanceFocusedRow = True
        MoUcnVersionsChangesUC.tlTreeList.OptionsView.ShowColumns = True
        MoUcnVersionsChangesUC.tlTreeList.OptionsView.ShowCheckBoxes = False
        MoUcnVersionsChangesUC.tlTreeList.OptionsView.ShowRoot = False
    End Sub
    Private Sub MoUcnVersionsChangesUC_MMCreateDataSource() Handles MoUcnVersionsChangesUC.MMCreateDataSource
        'ATTENTION: keep the same order here and during adding rows to DataSource
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(0).FieldName = "RowID"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(1).FieldName = "ParentRowID"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(2).FieldName = "Enabled"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(3).FieldName = "Selected"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(4).FieldName = "Location1"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(5).FieldName = "Location2"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(6).FieldName = "Location3"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(7).FieldName = "Operation"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(8).FieldName = "OldValue"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(9).FieldName = "NewValue"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(10).FieldName = "Description"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(11).FieldName = "UnitID"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(12).FieldName = "TableID"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(13).FieldName = "ColumnID"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(14).FieldName = "NoteID"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(15).FieldName = "HumanItemType"
        MoUcnVersionsChangesUC.tlTreeList.Columns.Add()
        MoUcnVersionsChangesUC.tlTreeList.Columns(16).FieldName = "HumanOperationType"

        'MoUcnVersionsChangesUC.tlTreeList.Columns(1).VisibleIndex = 1
        'MoUcnVersionsChangesUC.tlTreeList.Columns(2).VisibleIndex = 2
        'MoUcnVersionsChangesUC.tlTreeList.Columns(3).VisibleIndex = 3
        'MoUcnVersionsChangesUC.tlTreeList.Columns(4).VisibleIndex = 4
        'MoUcnVersionsChangesUC.tlTreeList.Columns(5).VisibleIndex = 5
        'MoUcnVersionsChangesUC.tlTreeList.Columns(6).VisibleIndex = 6
        'MoUcnVersionsChangesUC.tlTreeList.Columns(7).VisibleIndex = 7
        'MoUcnVersionsChangesUC.tlTreeList.Columns(8).VisibleIndex = 8
        'MoUcnVersionsChangesUC.tlTreeList.Columns(9).VisibleIndex = 9
        'MoUcnVersionsChangesUC.tlTreeList.Columns(10).VisibleIndex = 10
        'MoUcnVersionsChangesUC.tlTreeList.Columns(11).VisibleIndex = 12
        'MoUcnVersionsChangesUC.tlTreeList.Columns(12).VisibleIndex = 13
        'MoUcnVersionsChangesUC.tlTreeList.Columns(13).VisibleIndex = 14
        'MoUcnVersionsChangesUC.tlTreeList.Columns(14).VisibleIndex = 15
        'MoUcnVersionsChangesUC.tlTreeList.Columns(15).VisibleIndex = 16
        'MoUcnVersionsChangesUC.tlTreeList.Columns(16).VisibleIndex = 17

        MoUcnVersionsChangesUC.tlTreeList.Columns(4).VisibleIndex = 1
        MoUcnVersionsChangesUC.tlTreeList.Columns(15).VisibleIndex = 2
        MoUcnVersionsChangesUC.tlTreeList.Columns(16).VisibleIndex = 3
        '"RowID" AND "ParentRowID" ARE UNIQUE IDENTIFIERS FOR TREELIST AND THESE COLUMNS ARE INVISIBLE IN TREELIST COZ THEY ARE SET TO PROPERTIES KeyFieldName and ParentFieldName PROPERTIES OF TREELIST
    End Sub
    Private Sub MoUcnVersionsChangesUC_MMColumnProperties(ByRef Column As DevExpress.XtraTreeList.Columns.TreeListColumn) Handles MoUcnVersionsChangesUC.MMColumnProperties
        Try
            Select Case Column.FieldName
                Case AMod2.DsChanges.TableSysnames.Main.Columns.Location1
                    Column.Caption = "Nazov"
                    Column.OptionsColumn.AllowEdit = False
                    Column.SortOrder = SortOrder.Ascending
                Case "HumanItemType"
                    Column.Caption = "Objekt"
                    Column.OptionsColumn.AllowEdit = False
                Case "HumanOperationType"
                    Column.Caption = "Operacia"
                    Column.OptionsColumn.AllowEdit = False
                Case Else
                    'Column.Caption will be the same like Column.FieldName
                    Column.VisibleIndex = -1
                    Column.OptionsColumn.AllowEdit = False
            End Select
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    Private Sub MoUcnVersionsChangesUC_MMFillDataSource(ByVal Item As Object, ByRef DataSource As Microsoft.VisualBasic.Collection) Handles MoUcnVersionsChangesUC.MMFillDataSource
        Try
            Dim LsHumanItemType As String = ""
            Dim LsHumanOperationType As String = ""
            Dim LiI As Integer = 0
            For Each LoDataRow As DataRow In MoDSversionCompare.DsChanges.MainTable.Rows
                LiI = LiI + 1
                Select Case LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(0, 1)
                    Case "1" : LsHumanItemType = "tabulka"
                    Case "2" : LsHumanItemType = "polozka"
                    Case "3" : LsHumanItemType = "formular"
                    Case "4" : LsHumanItemType = "vztah"
                    Case "5" : LsHumanItemType = "poznamka"
                End Select
                Select Case LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                    Case "1" : LsHumanOperationType = "pridane"
                    Case "2" : LsHumanOperationType = "odobrane"
                    Case "3" : LsHumanOperationType = "zmenene"
                End Select
                DataSource.Add(New ClsUcnGridUnboundItemVersionsAllChanges(0 + LiI, -1, True, False, LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location2), LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3), LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation), LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.OldValue), LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.NewValue), LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.Description), LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.UnitId), LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.ColumnId), LoDataRow(AMod2.DsChanges.TableSysnames.Main.Columns.NoteId), LsHumanItemType, LsHumanOperationType))
            Next
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    Private Sub MoUcnVersionsChangesUC_MMRowDoubleClicked(ByVal Row As DevExpress.XtraTreeList.Nodes.TreeListNode) Handles MoUcnVersionsChangesUC.MMRowDoubleClicked
        'CASE SENSITIVE???
        Dim LiUnitID As Integer = Row("UnitID")
        Dim LiTableID As Integer = Row("TableID")
        Dim LiColumnID As Integer = Row("ColumnID")
        Dim LiNoteID As Integer = Row("NoteID")
        'CASE SENSITIVE???

        Dim LiFinalID As Integer = -1
        LiColumnID = IIf(LiColumnID = 0, -1, LiColumnID)
        Dim LoFinalitem As DiagramItem = Nothing
        Dim LbContinue As Boolean = True

        If LiUnitID <> 0 Then
            LiFinalID = LiUnitID
        ElseIf LiTableID <> 0 Then
            LiFinalID = LiTableID
        ElseIf LiNoteID <> 0 Then
            LiFinalID = LiNoteID
            'If LiColumnID <> 0 Then
            '    LiFinalID = LiColumnID
            'End If
        End If

        'select link if it has to be selected
        If Row(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(0, 1) = "4" Then
            Dim LoMMTableNode As ClsMMTableNode = Nothing
            Select Case Row(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                Case "1"
                    Select Case MeSideOfCanvas
                        Case GeSideOfCanvas.kkLeft
                            LoMMTableNode = GetNodeFromDiagramByID(LiTableID, MoRightCanvasBase.fcDiagram)
                            MoRightCanvasBase.RefreshSelectedItemProperties(LoMMTableNode.IncomingLinks(0), True)
                            LbContinue = False
                        Case GeSideOfCanvas.kkRight
                            LoMMTableNode = GetNodeFromDiagramByID(LiFinalID, fcDiagram)
                            RefreshSelectedItemProperties(LoMMTableNode.IncomingLinks(0), True)
                            LbContinue = False
                    End Select
                Case "3" 'special situation. Link can be added, removed, changed... Its hard to find out, so Ill try to select link in both canvases
                    Select Case MeSideOfCanvas
                        Case GeSideOfCanvas.kkLeft
                            Try
                                RefreshSelectedItemProperties(CType(GetNodeFromDiagramByID(LiTableID, fcDiagram), ClsMMTableNode).IncomingLinks(0), True)
                                LbContinue = False
                            Catch ex As Exception
                            End Try

                            If LbContinue Then
                                Try
                                    MoRightCanvasBase.RefreshSelectedItemProperties(CType(GetNodeFromDiagramByID(LiTableID, MoRightCanvasBase.fcDiagram), ClsMMTableNode).IncomingLinks(0), True)
                                    LbContinue = False
                                Catch ex As Exception
                                End Try
                            End If
                        Case GeSideOfCanvas.kkRight
                            Try
                                RefreshSelectedItemProperties(CType(GetNodeFromDiagramByID(LiTableID, fcDiagram), ClsMMTableNode).IncomingLinks(0), True)
                                LbContinue = False
                            Catch ex As Exception
                            End Try

                            If LbContinue Then
                                Try
                                    MoLeftCanvasBase.RefreshSelectedItemProperties(CType(GetNodeFromDiagramByID(LiTableID, MoLeftCanvasBase.fcDiagram), ClsMMTableNode).IncomingLinks(0), True)
                                    LbContinue = False
                                Catch ex As Exception
                                End Try
                            End If
                    End Select
            End Select
        End If

        If LbContinue Then
            'select other items than link
            Select Case Row(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                Case "1"
                    Select Case MeSideOfCanvas
                        Case GeSideOfCanvas.kkLeft
                            If LoFinalitem Is Nothing Then LoFinalitem = GetNodeFromDiagramByID(LiFinalID, MoRightCanvasBase.fcDiagram)
                            If LoFinalitem.GetType.Name = "ClsMMTableNode" Then CType(LoFinalitem, ClsMMTableNode).HighlightedRow = CType(LoFinalitem, ClsMMTableNode).MMGetRowIndexByColumnID(LiColumnID)
                            MoRightCanvasBase.RefreshSelectedItemProperties(LoFinalitem, True)
                        Case GeSideOfCanvas.kkRight
                            If LoFinalitem Is Nothing Then LoFinalitem = GetNodeFromDiagramByID(LiFinalID, fcDiagram)
                            If LoFinalitem.GetType.Name = "ClsMMTableNode" Then CType(LoFinalitem, ClsMMTableNode).HighlightedRow = CType(LoFinalitem, ClsMMTableNode).MMGetRowIndexByColumnID(LiColumnID)
                            RefreshSelectedItemProperties(LoFinalitem, True)
                    End Select
                Case "2"
                    Select Case MeSideOfCanvas
                        Case GeSideOfCanvas.kkLeft
                            If LoFinalitem Is Nothing Then LoFinalitem = GetNodeFromDiagramByID(LiFinalID, fcDiagram)
                            If LoFinalitem.GetType.Name = "ClsMMTableNode" Then CType(LoFinalitem, ClsMMTableNode).HighlightedRow = CType(LoFinalitem, ClsMMTableNode).MMGetRowIndexByColumnID(LiColumnID)
                            RefreshSelectedItemProperties(LoFinalitem, True)
                        Case GeSideOfCanvas.kkRight
                            If LoFinalitem Is Nothing Then LoFinalitem = GetNodeFromDiagramByID(LiFinalID, MoLeftCanvasBase.fcDiagram)
                            If LoFinalitem.GetType.Name = "ClsMMTableNode" Then CType(LoFinalitem, ClsMMTableNode).HighlightedRow = CType(LoFinalitem, ClsMMTableNode).MMGetRowIndexByColumnID(LiColumnID)
                            MoLeftCanvasBase.RefreshSelectedItemProperties(LoFinalitem, True)
                    End Select
                Case "3"
                    If LoFinalitem Is Nothing Then LoFinalitem = GetNodeFromDiagramByID(LiFinalID, fcDiagram)
                    If LoFinalitem.GetType.Name = "ClsMMTableNode" Then CType(LoFinalitem, ClsMMTableNode).HighlightedRow = CType(LoFinalitem, ClsMMTableNode).MMGetRowIndexByColumnID(LiColumnID)
                    RefreshSelectedItemProperties(LoFinalitem, True)
            End Select
        End If
    End Sub
#End Region
#Region "MoDSaModSolutionFile - Events handler"
    Private Sub MoDSaModSolutionFile_MMFileWasChanged() Handles MoDSaModSolutionFile.MMFileWasChanged
        SetEnableMenuAfterChangeOfStateOfFile()
        MakeTabPageCaption()
    End Sub
#End Region
#Region "MoAmodVersion - Events handler"
    Private Sub MoAmodVersion_MMWasChanged() Handles MoAmodVersion.MMWasChanged
        SetEnableMenuAfterChangeOfStateOfFile()
        MakeTabPageCaption()
    End Sub
#End Region
#Region "MoHand - Events handler"
    'OnChanGePrimaryOperationOfHand
    Private Sub MoHand_OnChanGePrimaryOperationOfHand(ByVal OldStatus As ModBase.GePrimaryOperationOfHand) Handles MoHand.OnChangePrimaryOperationOfHand
        ReflectPrimaryOperationOfHandOnForm(OldStatus)
    End Sub
    'OnChanGeSecondaryOperationOfHand
    Private Sub MoHand_OnChanGeSecondaryOperationOfHand(ByVal OldStatus As ModBase.GeSecondaryOperationOfHand) Handles MoHand.OnChangeSecondaryOperationOfHand
        ReflectSecondaryOperationOfHandOnForm(OldStatus)
    End Sub
    'OnChangeTypeOfLink
    Private Sub MoHand_OnChangeTypeOfLink(ByVal OldTypeOfLink As Integer) Handles MoHand.OnChangeTypeOfLink
        ReflectTypeOfLink(OldTypeOfLink)
    End Sub
#End Region
#Region "Panels + buttons - Events handler"
    'perform actions after panel is closed
    Private Sub MoDockPanelActions_ClosedPanel(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Docking.DockPanelEventArgs) Handles MoDockPanelActions.ClosedPanel
        barCheckItemPanelActions.Checked = False
    End Sub
    Private Sub MoDockPanelActions_VisibilityChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Docking.VisibilityChangedEventArgs) Handles MoDockPanelActions.VisibilityChanged
        Select Case e.Visibility
            Case DockVisibility.Hidden
                barCheckItemPanelActions.Checked = False
        End Select
    End Sub
    Private Sub MoDockPanelNotes_VisibilityChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Docking.VisibilityChangedEventArgs) Handles MoDockPanelNotes.VisibilityChanged
        Select Case e.Visibility
            Case DockVisibility.Hidden
                barCheckItemPanelNotes.Checked = False
        End Select
    End Sub
    Private Sub MoDockPanelOverview_VisibilityChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Docking.VisibilityChangedEventArgs) Handles MoDockPanelOverview.VisibilityChanged
        Select Case e.Visibility
            Case DockVisibility.Hidden
                barCheckItemPanelOverview.Checked = False
        End Select
    End Sub
    Private Sub MoDockPanelProperties_VisibilityChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Docking.VisibilityChangedEventArgs) Handles MoDockPanelProperties.VisibilityChanged
        Select Case e.Visibility
            Case DockVisibility.Hidden
                barCheckItemPanelProperties.Checked = False
        End Select
    End Sub
    Private Sub MoDockPanelJoinedModulesInfo_VisibilityChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Docking.VisibilityChangedEventArgs) Handles MoDockPanelJoinedModulesInfo.VisibilityChanged
        Select Case e.Visibility
            Case DockVisibility.Hidden
                barCheckItemPanelJoinedModulesInfo.Checked = False
        End Select
    End Sub
    Private Sub MoDockPanelItemChanges_VisibilityChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Docking.VisibilityChangedEventArgs) Handles MoDockPanelItemChanges.VisibilityChanged
        Select Case e.Visibility
            Case DockVisibility.Hidden
                barCheckItemPanelItemChanges.Checked = False
        End Select
    End Sub
    Private Sub MoDockPanelVersionsChanges_VisibilityChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.Docking.VisibilityChangedEventArgs) Handles MoDockPanelVersionsChanges.VisibilityChanged
        Select Case e.Visibility
            Case DockVisibility.Hidden
                barCheckItemPanelVersionsChanges.Checked = False
        End Select
    End Sub
#End Region
#Region "Menu - Events handler"
#Region "Zoom"
    Private Sub fcDiagramView_ZoomFactorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles fcDiagramView.ZoomFactorChanged
        'if zoom factor is < 25 --> set zoom factor to 25
        If fcDiagramView.ZoomFactor < 25 Then
            ZoomCanvasFromZoom(25)
        End If

        ReflectZoom()
    End Sub
    Private Sub RepositoryCboZoom_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RepositoryCboZoom.KeyDown
        'I dont know why RepositoryCboZoom.ValidateOnEnterKey property is not working so I need to do a litlle fake how to accept chages after ENETR key --> calling RepositoryCboZoom_Validating
        Select Case e.KeyCode
            Case Keys.Enter 'ENTER
                Dim LoComboBoxEdit As DevExpress.XtraEditors.ComboBoxEdit = CType(sender, DevExpress.XtraEditors.ComboBoxEdit)
                RepositoryCboZoom_Validating(sender, New System.ComponentModel.CancelEventArgs)
        End Select
    End Sub
    Private Sub RepositoryCboZoom_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles RepositoryCboZoom.Validating
        'its quite odd how to set zoom factor and how to control RepositoryCboZoom, barCboZoom and sender objects :-)
        Dim LoComboBoxEdit As DevExpress.XtraEditors.ComboBoxEdit = CType(sender, DevExpress.XtraEditors.ComboBoxEdit)
        Dim LsOriginalValue As String = LoComboBoxEdit.Text
        Dim LsNumericValue As String = ""
        Dim LdcNumericValue As Decimal = -1

        Try
            If GetNumericString(LsOriginalValue, LsNumericValue) = GeActionResult.kkOk Then
                Try
                    LdcNumericValue = CDec(LsNumericValue)
                Catch ex As Exception
                    LdcNumericValue = fcDiagramView.ZoomFactor
                End Try
                ZoomCanvasFromZoom(LdcNumericValue)
                'now after ReflectZoom called from ZoomCanvasFromZoom barCboZoom.EditValue has proper value "XY%" so i can assign it to LoComboBoxEdit.Text 
                LoComboBoxEdit.Text = barCboZoom.EditValue
                'focuses fcDiagramView
                FocusDiagramView()
            End If
        Catch ex As Exception
            LogEventFromException(ex, , , )
            'focuses fcDiagramView
            FocusDiagramView()
        End Try
    End Sub
    Private Sub RepositoryEditZoom_EditValueChanging(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.ChangingEventArgs) Handles RepositoryEditZoom.EditValueChanging
        ZoomCanvasFromZoom(e.NewValue * (1500 / RepositoryEditZoom.Maximum))
    End Sub
    Private Sub RepositoryEditZoom_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RepositoryEditZoom.MouseUp
        'focuses fcDiagramView
        FocusDiagramView()
    End Sub
#End Region
#Region "Appearance"
    Private Sub RepositoryCheckShowGrid_EditValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RepositoryCheckShowGrid.EditValueChanged
        fcDiagram.ShowGrid = CType(sender, DevExpress.XtraEditors.CheckEdit).EditValue

        FocusDiagramView()
    End Sub
    Private Sub RepositoryCboTypeOfGrid_EditValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RepositoryCboTypeOfGrid.EditValueChanged
        Try
            Select Case CType(sender, DevExpress.XtraEditors.ComboBoxEdit).Text
                Case "Ciary" : fcDiagram.GridStyle = GridStyle.Lines
                Case "Bodky" : fcDiagram.GridStyle = GridStyle.Points
                Case Else : Throw New Exception
            End Select
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try

        FocusDiagramView()
    End Sub
    Private Sub RepositoryCheckShowHorizontalRuler_EditValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RepositoryCheckShowHorizontalRuler.EditValueChanged
        Me.fcRuler.HorizontalScaleVisible = CType(sender, DevExpress.XtraEditors.CheckEdit).EditValue

        FocusDiagramView()
    End Sub
    Private Sub RepositoryCheckShowVerticalRuler_EditValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RepositoryCheckShowVerticalRuler.EditValueChanged
        Me.fcRuler.VerticalScaleVisible = CType(sender, DevExpress.XtraEditors.CheckEdit).EditValue

        FocusDiagramView()
    End Sub
#End Region
#Region "Layout"
    Private Sub MoDiagramLayout_MMAfterArranged(ByVal TypeOfLayout As ModBase.GeTypeOfLayout) Handles MoDiagramLayout.MMAfterArranged
        SetFileWasModified(True)
    End Sub
    Private Sub barBtnLayeredLayout_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnLayeredLayout.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkLayoutDiagram)
        LoAction.SetData(GeTypeOfLayout.kkLayeredLayout, "LAYOUTENGINE")
        Execute(LoAction)
    End Sub
    Private Sub barBtnSpringLayout_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnSpringLayout.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkLayoutDiagram)
        LoAction.SetData(GeTypeOfLayout.kkSpringLayout, "LAYOUTENGINE")
        Execute(LoAction)
    End Sub
    Private Sub barBtnTreeLayout_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnTreeLayout.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkLayoutDiagram)
        LoAction.SetData(GeTypeOfLayout.kkTreeLayout, "LAYOUTENGINE")
        Execute(LoAction)
    End Sub
    Private Sub barBtnAnnealLayout_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnAnnealLayout.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkLayoutDiagram)
        LoAction.SetData(GeTypeOfLayout.kkAnnealLayout, "LAYOUTENGINE")
        Execute(LoAction)
    End Sub
    Private Sub barBtnOrthogonalLayout_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnOrthogonalLayout.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkLayoutDiagram)
        LoAction.SetData(GeTypeOfLayout.kkOrthogonalLayout, "LAYOUTENGINE")
        Execute(LoAction)
    End Sub
    Private Sub barBtnCircularLayout_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnCircularLayout.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkLayoutDiagram)
        LoAction.SetData(GeTypeOfLayout.kkCircularLayout, "LAYOUTENGINE")
        Execute(LoAction)
    End Sub
    Private Sub barBtnOrthogonalRouter_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnOrthogonalRouter.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkLayoutDiagram)
        LoAction.SetData(GeTypeOfLayout.kkOrthogonalRouter, "LAYOUTENGINE")
        Execute(LoAction)
    End Sub
    Private Sub barBtnFlowLayout_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnFlowLayout.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkLayoutDiagram)
        LoAction.SetData(GeTypeOfLayout.kkFlowLayout, "LAYOUTENGINE")
        Execute(LoAction)
    End Sub
    Private Sub barBtnFlowchartLayout_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnFlowchartLayout.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkLayoutDiagram)
        LoAction.SetData(GeTypeOfLayout.kkFlowchartLayout, "LAYOUTENGINE")
        Execute(LoAction)
    End Sub
    Private Sub barBtnTopologicalLayout_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnTopologicalLayout.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkLayoutDiagram)
        LoAction.SetData(GeTypeOfLayout.kkTopologicalLayout, "LAYOUTENGINE")
        Execute(LoAction)
    End Sub
#End Region
#Region "Others"
    'new solution
    Private Sub barBtnNewSolution_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnNewSolution.ItemClick
        Select Case MoTabPage.TypeOfTab
            Case GeTypeOfTab.kkMainTab
                Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModSolutionNewSolution)
                Execute(LoAction)
        End Select
    End Sub
    'open solution
    Private Sub barBtnOpenSolution_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnOpenSolution.ItemClick
        If MoTabPage.TypeOfTab = GeTypeOfTab.kkMainTab Then
            OpenFileDialog.InitialDirectory = GetDesktopPath()
            OpenFileDialog.FileName = ""
            OpenFileDialog.Filter = "Subory aMod projektu(*.aModProj)|*.aModProj"
            OpenFileDialog.Title = "Otvorenie aMod projektu"
            If OpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
                Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModSolutionOpenFile)
                LoAction.SetData(OpenFileDialog.FileName, "AMODSOLUTIONFILEPATH")
                Execute(LoAction)
            End If
        End If
    End Sub
    'close solution
    Private Sub barBtnCloseSolution_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnCloseSolution.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkCloseTab)

        LoAction.SetData(True, "ASKFORCLOSINGPROJECT")
        MoTabPage.Execute(LoAction)
    End Sub
    'save solution
    Private Sub barBtnSaveSolution_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnSaveSolution.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModSolutionSaveFile)
        Execute(LoAction)
    End Sub
    'module versions management
    Private Sub barBtnVersionsManagement_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnVersionsManagement.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModVersionsManagement)
        Execute(LoAction)
    End Sub
    'promoting a version to actual one - last one
    Private Sub barBtnPromoteVersion_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnPromoteVersion.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkamodPromoteVersion)
        LoAction.SetData(MoDSaModFile.Path, "AMODPATHFORPROMOTING")
        LoAction.SetData(AmodVersion.GetVersionVID, "VERSIONFORPROMOTING")
        Execute(LoAction)
    End Sub
    'generating VS project from solution
    Private Sub barBtnExportAmodSolutionToProject_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnExportAmodSolutionToProject.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModExportAmodSolutionToProject)
        Execute(LoAction)
    End Sub
    'generating form from unit
    Private Sub barBtnExportUnitsToForms_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnExportUnitsToForms.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkamodExportUnitsToForms)
        LoAction.SetData(AmodVersion, "DSAMODONEVERSION")
        LoAction.SetData(MoDSaModFile.Path, "AMODPATH")
        Execute(LoAction)
    End Sub
    'export module to xMod
    Private Sub barBtnExportModuleToXmod_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnExportModuleToXmod.ItemClick
        If MoTabPage.TypeOfTab = GeTypeOfTab.kkClassDiagramTab Then
            Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModExportModuleToXmod)
            LoAction.SetData(AmodVersion.GetVersionVID, "VERSIONFOREXPORT")
            Execute(LoAction)
        End If
    End Sub
    'import module from xMod
    Private Sub barBtnImportModuleFromXmod_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnImportModuleFromXmod.ItemClick
        If MoTabPage.TypeOfTab = GeTypeOfTab.kkClassDiagramTab Then
            Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModImportModuleFromXmod)
            LoAction.SetData(MoDSaModFile.Path, "AMODPATHFORIMPORT")
            LoAction.SetData(AmodVersion.GetVersionVID, "VERSIONFORIMPORT")
            Execute(LoAction)
        End If
    End Sub
    'import unit from form
    Private Sub barBtnImportUnitsFromForms_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnImportUnitsFromForms.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkamodImportUnitsFromForms)
        LoAction.SetData(AmodVersion, "DSAMODONEVERSION")
        LoAction.SetData(MoDSaModFile.Path, "AMODPATH")
        Execute(LoAction)
    End Sub
    'save module = save version and then save file
    Private Sub barBtnSaveModule_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnSaveModule.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModSaveVersionAndFile)
        Execute(LoAction)
    End Sub
    'open use case diagram of module
    Private Sub barBtnOpenUCDofModule_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnOpenUCDmodule.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModTryToOpenUCDofModule)
        LoAction.SetData(MoDSaModFile.Path, "PATHTOFILE")
        MoTabPage.Execute(LoAction)
    End Sub
    'save use case diagram of module
    Private Sub barBtnSaveUCDofModule_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnSaveUCDofModule.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModSaveUCDofModuleAndFile)
        Execute(LoAction)
    End Sub
    'close use case diagram of module
    Private Sub barBtnCloseUCDofModule_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnCloseUCDdiagram.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkCloseTab)
        MoTabPage.Execute(LoAction)
    End Sub
    'close module
    Private Sub barBtnCloseModule_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnCloseModule.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkCloseTab)
        MoTabPage.Execute(LoAction)
    End Sub
    Private Sub barCheckItemPanelActions_CheckedChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barCheckItemPanelActions.CheckedChanged
        If barCheckItemPanelActions.Checked Then
            MoDockPanelActions.Show()
        Else
            MoDockPanelActions.Close()
        End If
    End Sub
    Private Sub barCheckItemPanelNotes_CheckedChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barCheckItemPanelNotes.CheckedChanged
        If barCheckItemPanelNotes.Checked Then
            MoDockPanelNotes.Show()
        Else
            MoDockPanelNotes.Close()
        End If
    End Sub
    Private Sub barCheckItemPanelOverview_CheckedChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barCheckItemPanelOverview.CheckedChanged
        If barCheckItemPanelOverview.Checked Then
            MoDockPanelOverview.Show()
        Else
            MoDockPanelOverview.Close()
        End If
    End Sub
    Private Sub barCheckItemPanelProperties_CheckedChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barCheckItemPanelProperties.CheckedChanged
        If barCheckItemPanelProperties.Checked Then
            MoDockPanelProperties.Show()
        Else
            MoDockPanelProperties.Close()
        End If
    End Sub
    Private Sub barCheckItemPanelJoinedModulesInfo_CheckedChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barCheckItemPanelJoinedModulesInfo.CheckedChanged
        If barCheckItemPanelJoinedModulesInfo.Checked Then
            MoDockPanelJoinedModulesInfo.Show()
        Else
            MoDockPanelJoinedModulesInfo.Close()
        End If
    End Sub
    Private Sub barCheckItemPanelItemChanges_CheckedChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barCheckItemPanelItemChanges.CheckedChanged
        If barCheckItemPanelItemChanges.Checked Then
            MoDockPanelItemChanges.Show()
        Else
            MoDockPanelItemChanges.Close()
        End If
    End Sub
    Private Sub barCheckItemPanelVersionsChanges_CheckedChanged(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barCheckItemPanelVersionsChanges.CheckedChanged
        If barCheckItemPanelVersionsChanges.Checked Then
            MoDockPanelVersionsChanges.Show()
        Else
            MoDockPanelVersionsChanges.Close()
        End If
    End Sub
    'locate module file
    Private Sub barBtnOpenTargetModule_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnOpenTargetModule.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModOpenPathTarget)
        Execute(LoAction)
    End Sub
    'locate solution file
    Private Sub barBtnOpenTargetSolution_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnOpenTargetSolution.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModSolutionOpenPathTarget)
        Execute(LoAction)
    End Sub
    'save all = aMod solution, aMod versions, use case diagrams
    Private Sub barBtnSaveAll_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles barBtnSaveAll.ItemClick
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkSaveAll)
        Execute(LoAction)
    End Sub
#End Region
#End Region
#End Region
#Region "Functions"
    'returns if anchorpoint is free for accepting a new link
    Private Function IsFreeAnchorPoint(ByVal IoNode As DiagramNode, ByVal IoLink As DiagramLink, ByVal IoAnchorIndex As Integer, ByVal IiMaxNumberOfLinks As Integer) As Boolean
        Dim LoLink As DiagramLink
        Dim LiI, LiActualNumberOfLinks As Integer
        Dim LbOk As Boolean

        If IoLink IsNot Nothing Then
            LiActualNumberOfLinks = 0
            'checking IncomingLinks
            LiI = 0
            LbOk = True
            LoLink = IoNode.IncomingLinks.GetAt(LiI)
            While (LoLink IsNot Nothing) And (LbOk)
                If Not IoLink.DestinationAnchor.Equals(LoLink.DestinationAnchor) Then 'prevention of selfchecking of link
                    If LoLink.DestinationAnchor = IoAnchorIndex Then
                        LiActualNumberOfLinks += 1
                        If LiActualNumberOfLinks >= IiMaxNumberOfLinks Then LbOk = False
                    End If
                End If
                LiI += 1
                LoLink = IoNode.IncomingLinks.GetAt(LiI)
            End While

            'checking OutgoingLinks
            If LiActualNumberOfLinks < IiMaxNumberOfLinks Then
                LiI = 0
                LbOk = True
                LoLink = IoNode.OutgoingLinks.GetAt(LiI)
                While (LoLink IsNot Nothing) And (LbOk)
                    If Not IoLink.OriginAnchor.Equals(LoLink.OriginAnchor) Then 'prevention of selfchecking of link
                        If LoLink.OriginAnchor = IoAnchorIndex Then
                            LiActualNumberOfLinks += 1
                            If LiActualNumberOfLinks >= IiMaxNumberOfLinks Then LbOk = False
                        End If
                    End If
                    LiI += 1
                    LoLink = IoNode.OutgoingLinks.GetAt(LiI)
                End While
            End If
        End If

        Return LiActualNumberOfLinks < IiMaxNumberOfLinks
    End Function
    'checking rules for creation/modification of new link
    Private Function CheckLinkRules(ByVal IiMMLinkNode As ClsMMLinkNode, ByVal IoNode As DiagramNode, ByVal IoOrigin As DiagramNode, ByVal IoDestination As DiagramNode, ByVal IbModifying As Boolean) As Boolean
        Dim LbOk As Boolean = True

        'prevention of creation of link on the same node 
        LbOk = IIf(IoDestination.Equals(IoOrigin), False, True)

        'checking rules for creating of link
        If LbOk = True Then
            Select Case IiMMLinkNode.MMTypeOfLink
                Case GeTypeOfLink.kkClassDiagramRelationship
                    If IoNode IsNot Nothing Then
                        'accepting only table for creating a link
                        If (IoNode.GetType.Name = "ClsMMTableNode") Then
                            Dim LoMMTableNode As ClsMMTableNode = CType(IoNode, ClsMMTableNode)

                            'its allowed to link a link if it was linked to this table
                            'Im checking IiMMLinkNode.Origin and IiMMLinkNode.Destination and no IoOrigin and IoDestination coz while creating a new link, they are temporary set to nodes from under the cursor
                            If (IiMMLinkNode.Origin IsNot Nothing AndAlso IiMMLinkNode.Origin.Equals(LoMMTableNode)) Or (IiMMLinkNode.Destination IsNot Nothing AndAlso IiMMLinkNode.Destination.Equals(LoMMTableNode)) Then
                                LbOk = True
                            Else
                                'perfoming some tests if link which wasnt linked to this table is modified
                                If LoMMTableNode.MMGetNumberOfRelationshipsLinks(True) > 0 Then
                                    'prevention of multiple parent in DS hierarchy
                                    LbOk = False
                                Else
                                    'prevention of cycle between nodes
                                    LbOk = Not IsPathBetweenNodes(IoOrigin, IoDestination, GeTypeOfLink.kkClassDiagramRelationship)
                                End If
                            End If
                        Else
                            LbOk = False
                        End If
                    End If
                Case GeTypeOfLink.kkNote
                    If IbModifying Then
                        'prevention of deconnecting link from note shape while modifying
                        LbOk = IIf(IoDestination.GetType.Name <> "ClsMMNoteNode" And IoOrigin.GetType.Name <> "ClsMMNoteNode", False, True)
                        'prevenion of creating more connection between same nodes
                        If LbOk Then
                            If (IiMMLinkNode.Origin IsNot Nothing AndAlso IiMMLinkNode.Origin.Equals(IoNode)) Or (IiMMLinkNode.Destination IsNot Nothing AndAlso IiMMLinkNode.Destination.Equals(IoNode)) Then
                                LbOk = True
                            Else
                                LbOk = Not IsPathBetweenNodes(IoOrigin, IoDestination, GeTypeOfLink.kkNote)
                            End If
                        End If
                    Else
                        LbOk = Not IsPathBetweenNodes(IoOrigin, IoDestination, GeTypeOfLink.kkNote)
                    End If
            End Select
        Else
            Debug.Print("CHYBA!!! - CheckLinkRules - IoDestination.Equals(IoOrigin)")
        End If

        Return LbOk
    End Function
    'examine possibility to drop node to container
    Private Function AllowDropNodeToContainer(ByVal LoCoordinate As PointF) As ClsMMContainerNode
        Dim LoNodesUnderCursor As DiagramNodeCollection = Me.fcDiagram.GetNodesAt(LoCoordinate)
        Dim LoMMContainerResult As ClsMMContainerNode = Nothing

        For Each LoNode As DiagramNode In LoNodesUnderCursor
            Select Case LoNode.GetType.Name
                Case "ClsMMContainerNode"
                    LoMMContainerResult = CType(LoNode, ClsMMContainerNode)
                    Exit For
            End Select
        Next

        Return LoMMContainerResult

        ' ''Dim LoNodeUnderCursor As DiagramNode = Me.fcDiagram.GetNodeAt(LoCoordinate)
        ' ''If LoNodeUnderCursor IsNot Nothing Then
        ' ''    If LoNodeUnderCursor.GetType.Name = "ClsMMContainerNode" Then
        ' ''        Return CType(LoNodeUnderCursor, ClsMMContainerNode)
        ' ''    Else
        ' ''        Return Nothing
        ' ''    End If
        ' ''Else
        ' ''    Return Nothing
        ' ''End If
    End Function
    'examine possibility to drop node outside of container
    Private Function AllowDropNodeOutsideOfContainer(ByVal LoCoordinate As PointF) As ClsMMContainerNode
        Dim LoNodesUnderCursor As DiagramNodeCollection = Me.fcDiagram.GetNodesAt(LoCoordinate)
        Dim LoMMContainerResult As ClsMMContainerNode = Nothing

        For Each LoNode As DiagramNode In LoNodesUnderCursor
            Select Case LoNode.GetType.Name
                Case "ClsMMContainerNode"
                    LoMMContainerResult = CType(LoNode, ClsMMContainerNode)
                    Exit For
            End Select
        Next

        Return LoMMContainerResult
    End Function
    'finds out if there is already connection between 2 nodes consist of specified type of links
    Private Function IsPathBetweenNodes(ByVal IoStartingNode As DiagramNode, ByVal IoEndingNode As DiagramNode, ByVal IeTypeOfLinks As GeTypeOfLink) As Boolean
        Dim LoPathFinder As New PathFinder(Me.fcDiagram, True)
        Dim LoPath As Path = LoPathFinder.FindShortestPath(IoStartingNode, IoEndingNode)
        Dim LbResult As Boolean = True

        If LoPath IsNot Nothing Then
            Select Case IeTypeOfLinks
                Case GeTypeOfLink.kkClassDiagramRelationship
                    'checking path consist of relationship links
                    For Each LoLink In LoPath.Links
                        Select Case LoLink.GetType.Name
                            Case "ClsMMLinkNode"
                                Select Case CType(LoLink, ClsMMLinkNode).MMTypeOfLink
                                    Case GeTypeOfLink.kkNote
                                        LbResult = False
                                        Exit For
                                End Select
                            Case Else
                                Debug.Print("CHYBA!!! - IsPathBetweenNodes - IeTypeOfLinks=kkClassDiagramRelationship - Select Case LoLink.GetType.Name")
                        End Select
                    Next
                Case GeTypeOfLink.kkNote
                    'checking path length 1 consist of note links = if theres direct connection between 2 nodes (e.g. connection length 1)
                    If LoPath.Length = 1 Then
                        Dim LoLink As DiagramLink = LoPath.Links(0)
                        Select Case LoLink.GetType.Name
                            Case "ClsMMLinkNode"
                                If CType(LoLink, ClsMMLinkNode).MMTypeOfLink = GeTypeOfLink.kkNote Then
                                    LbResult = True
                                Else
                                    LbResult = False
                                End If
                            Case Else
                                Debug.Print("CHYBA!!! - IsPathBetweenNodes - IeTypeOfLinks=kkNote - Select Case LoPath.Items(0).GetType.Name")
                        End Select
                    Else
                        LbResult = False
                    End If
            End Select
        Else
            LbResult = False
        End If

        Return LbResult
    End Function
    'returns created new node
    Private Function CreateNewNode(ByVal IeTypeOfNode As GeTypeOfItems) As DiagramNode
        Select Case IeTypeOfNode
            Case GePrimaryOperationOfHand.kkNeutral
                Debug.Print("CHYBA!!! - GetNewNode - Select Case IePrimaryOperationOfHand")
                Return Nothing
            Case GeTypeOfItems.kkTable
                Return New ClsMMTableNode(Me.fcDiagram)
            Case GeTypeOfItems.kkContainer
                Return New ClsMMContainerNode(Me.fcDiagram)
            Case GeTypeOfItems.kkModule
                Return New ClsMMModuleNode(Me.fcDiagram)
            Case GeTypeOfItems.kkNote
                Return New ClsMMNoteNode(Me.fcDiagram)
            Case GeTypeOfItems.kkActor
                Return New ClsMMActorNode(Me.fcDiagram)
            Case GeTypeOfItems.kkActivity
                Return New ClsMMActivityNode(Me.fcDiagram)
            Case GeTypeOfItems.kkSystemBoundary
                Return New ClsMMSystemBoundaryNode(Me.fcDiagram)
            Case Else
                Debug.Print("CHYBA!!! - GetNewNode")
                Return Nothing
        End Select
    End Function
    'builds whole graphic diagram from DS
    Public Function BuildWholeDiagram() As GeActionResult
        Try
            'ATTENTION! All nodes have to be inserted into diagram before you can perform some actions on them (e.g. inserting table to container)
            Dim LoAddedTables As Dictionary(Of String, ClsMMTableNode) = New Dictionary(Of String, ClsMMTableNode) 'added tables into diagram - used during links creation

            'iterate all units
            For Each LoUnitRow As DataRow In MoAmodVersion.DSaModVersion.UnitsTable.Rows
                Dim LoMMContainerNode As ClsMMContainerNode = New ClsMMContainerNode
                LoMMContainerNode.Caption = LoUnitRow(AMod2.DsAModOneVersion.TableSysnames.Units.Columns.HumanUnitName)
                LoMMContainerNode.UnitName = LoUnitRow(AMod2.DsAModOneVersion.TableSysnames.Units.Columns.UnitName)
                LoMMContainerNode.ID = LoUnitRow(AMod2.DsAModOneVersion.TableSysnames.Units.Columns.ID)
                fcDiagram.Nodes.Add(LoMMContainerNode)

                'all tables from tablelist belonging to this unit
                Dim LoIncludedTablesRows As DataRow() = MoAmodVersion.DSaModVersion.TableListTable.Select(String.Format("{0}='{1}' AND {2}={3}", AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName, LoMMContainerNode.UnitName, KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.TableType, CInt(KrosLib.Data.eTableType.DataTable)))
                'Dim VSETKYTABULKY As DataRow() = MoAmodVersion.DSaModVersion.TableListTable.Select(String.Format("{0}='{1}'", AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName, LoMMContainerNode.UnitName))

                'If LoIncludedTablesRows.Count <> VSETKYTABULKY.Count Then MessageBox.Show("Preskakujem ine typy tabuliek... JUCHU!")

                'iterate tables from tablelist and get real datatables
                For Each LoIncludedTablesRow As DataRow In LoIncludedTablesRows
                    Dim LoMMTableNode As ClsMMTableNode = New ClsMMTableNode
                    LoMMTableNode.Caption = LoIncludedTablesRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.HumanTableName)
                    LoMMTableNode.AppTableName = LoIncludedTablesRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.AppTableName)
                    LoMMTableNode.ID = LoIncludedTablesRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.Id)
                    fcDiagram.Nodes.Add(LoMMTableNode)
                    'create NodeForNewLink
                    Dim LoMMNodeForNewLink As ClsMMNodeForNewLink = New ClsMMNodeForNewLink(LoMMTableNode.Bounds)
                    Me.fcDiagram.Nodes.Add(LoMMNodeForNewLink)
                    LoMMNodeForNewLink.AttachTo(LoMMTableNode, AttachToNode.TopRight)
                    LoMMNodeForNewLink.Visible = False 'after attaching, visibility is changed to true
                    LoMMTableNode.SubordinateGroup.AutoDeleteItems = True

                    'adding table with its AppTableName to collection of added tables into diagram
                    LoAddedTables.Add(LoMMTableNode.AppTableName, LoMMTableNode)

                    LoMMTableNode.MMRebuildTable(MoAmodVersion.GetDataTableAllRowsSortedByPosition(LoMMTableNode.AppTableName))
                    LoMMContainerNode.Add(LoMMTableNode)
                Next
            Next

            'iterate all relationships
            For Each LoRelationshipRow As DataRow In AmodVersion.GetMainHierarchyRowsFromHierarchy
                Dim LsParentTableName As String = LoRelationshipRow(KrosLib.Editors.xModDataSet.TableSysnames.Hierarchy.Columns.ParentTable)
                If LsParentTableName <> "" Then
                    Dim LoMMLinkNode As ClsMMLinkNode = New ClsMMLinkNode(fcDiagram)

                    LoMMLinkNode.Origin = LoAddedTables(LsParentTableName)
                    LoMMLinkNode.Destination = LoAddedTables(LoRelationshipRow(KrosLib.Editors.xModDataSet.TableSysnames.Hierarchy.Columns.TableName))

                    LoMMLinkNode.MMTypeOfLink = GeTypeOfLink.kkClassDiagramRelationship
                    LoMMLinkNode.MMRelationType = LoRelationshipRow(KrosLib.Editors.xModDataSet.TableSysnames.Hierarchy.Columns.RelationType)
                    LoMMLinkNode.SnapToNodeBorder = True
                    LoMMLinkNode.AutoRoute = True
                    LoMMLinkNode.Style = LinkStyle.Cascading
                    fcDiagram.Links.Add(LoMMLinkNode)
                End If
            Next

            'iterate all notes
            For Each LoNoteRow As DataRow In AmodVersion.DSaModVersion.NotesTable.Rows
                Dim LoMMNoteNode As ClsMMNoteNode = New ClsMMNoteNode(fcDiagram)

                LoMMNoteNode.Text = LoNoteRow(AMod2.DsAModOneVersion.TableSysnames.Notes.Columns.Text)
                LoMMNoteNode.ID = LoNoteRow(AMod2.DsAModOneVersion.TableSysnames.Notes.Columns.ID)
                fcDiagram.Nodes.Add(LoMMNoteNode)
                'create NodeForNewLink
                Dim LoMMNodeForNewLink As ClsMMNodeForNewLink = New ClsMMNodeForNewLink(LoMMNoteNode.Bounds)
                Me.fcDiagram.Nodes.Add(LoMMNodeForNewLink)
                LoMMNodeForNewLink.AttachTo(LoMMNoteNode, AttachToNode.TopRight)
                LoMMNodeForNewLink.Visible = False 'after attaching, visibility is changed to true
                LoMMNoteNode.SubordinateGroup.AutoDeleteItems = True
            Next


            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'builds graphic unit in diagram from DS
    Public Function BuildUnit(ByVal IsUnitName As String, ByVal IsHumanUnitName As String, ByVal IiUnitID As Integer) As GeActionResult
        Try
            Dim LoMMContainerNode As ClsMMContainerNode = New ClsMMContainerNode
            LoMMContainerNode.Caption = IsHumanUnitName
            LoMMContainerNode.UnitName = IsUnitName
            LoMMContainerNode.ID = IiUnitID
            fcDiagram.Nodes.Add(LoMMContainerNode)

            'all tables from tablelist belonging to this unit
            Dim LoIncludedTablesRows As DataRow() = MoAmodVersion.DSaModVersion.TableListTable.Select(String.Format("{0}='{1}' AND {2}={3}", AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName, LoMMContainerNode.UnitName, KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.TableType, CInt(KrosLib.Data.eTableType.DataTable)))

            'iterate tables from tablelist and get real datatables
            For Each LoIncludedTablesRow As DataRow In LoIncludedTablesRows
                BuildTable(LoIncludedTablesRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.TableName), LoIncludedTablesRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.HumanTableName), LoIncludedTablesRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.Id), LoMMContainerNode)
            Next

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'builds graphic table in diagram from DS
    Public Function BuildTable(ByVal IsTableName As String, ByVal IsHumanTableName As String, ByVal IiTableID As Integer, ByRef OoMMContainerNode As ClsMMContainerNode) As GeActionResult
        Try
            Dim LoMMTableNode As ClsMMTableNode = New ClsMMTableNode
            LoMMTableNode.Caption = IsHumanTableName
            LoMMTableNode.AppTableName = IsTableName
            LoMMTableNode.ID = IiTableID
            fcDiagram.Nodes.Add(LoMMTableNode)
            'create NodeForNewLink
            Dim LoMMNodeForNewLink As ClsMMNodeForNewLink = New ClsMMNodeForNewLink(LoMMTableNode.Bounds)
            Me.fcDiagram.Nodes.Add(LoMMNodeForNewLink)
            LoMMNodeForNewLink.AttachTo(LoMMTableNode, AttachToNode.TopRight)
            LoMMNodeForNewLink.Visible = False 'after attaching, visibility is changed to true
            LoMMTableNode.SubordinateGroup.AutoDeleteItems = True

            LoMMTableNode.MMRebuildTable(MoAmodVersion.GetDataTableAllRowsSortedByPosition(LoMMTableNode.AppTableName))
            OoMMContainerNode.Add(LoMMTableNode)

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'builds graphic relationships (between tables from unit) in diagram from DS
    Public Function BuildRelationshipsBetweenUnitTables(ByVal IsUnitName As String) As GeActionResult
        Try
            'get all unit child tables
            Dim LoUnitTablesNames As Collection = New Collection
            For Each LoRow As DataRow In AmodVersion.DSaModVersion.HierarchyTable.Select(String.Format("{0}='{1}'", AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName, IsUnitName))
                LoUnitTablesNames.Add(LoRow(AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName))
            Next

            'iterating tables - as children
            For Each LoTableName As String In LoUnitTablesNames
                Dim LoParentMMTableNode As ClsMMTableNode = GetTableFromDiagramByTableName(LoTableName, fcDiagram)
                'iterating parent tables
                For Each LoRelationShipRow As DataRow In AmodVersion.GetChildTablesFromHierarchyFromMainHierarchy(LoTableName)
                    Dim LsChildTableName As String = LoRelationShipRow(KrosLib.Editors.xModDataSet.TableSysnames.Hierarchy.Columns.TableName)

                    Dim LoMMLinkNode As ClsMMLinkNode = New ClsMMLinkNode(fcDiagram)

                    LoMMLinkNode.Origin = LoParentMMTableNode
                    LoMMLinkNode.Destination = GetTableFromDiagramByTableName(LsChildTableName, fcDiagram)

                    LoMMLinkNode.MMTypeOfLink = GeTypeOfLink.kkClassDiagramRelationship
                    LoMMLinkNode.MMRelationType = LoRelationShipRow(KrosLib.Editors.xModDataSet.TableSysnames.Hierarchy.Columns.RelationType)
                    LoMMLinkNode.SnapToNodeBorder = True
                    LoMMLinkNode.AutoRoute = True
                    LoMMLinkNode.Style = LinkStyle.Cascading
                    fcDiagram.Links.Add(LoMMLinkNode)
                Next
            Next

            'iterating tables - as parents
            For Each LoTableName As String In LoUnitTablesNames
                Dim LoChildMMTableNode As ClsMMTableNode = GetTableFromDiagramByTableName(LoTableName, fcDiagram)
                'iterating child tables
                Dim LoParentRelationShipRow As DataRow = AmodVersion.GetHierarchyRowFromMainHierarchyByTableName(LoTableName)
                Dim LsParentTableName As String = LoParentRelationShipRow(KrosLib.Editors.xModDataSet.TableSysnames.Hierarchy.Columns.ParentTable)

                Dim LoMMLinkNode As ClsMMLinkNode = New ClsMMLinkNode(fcDiagram)

                LoMMLinkNode.Origin = GetTableFromDiagramByTableName(LsParentTableName, fcDiagram)
                LoMMLinkNode.Destination = LoChildMMTableNode

                LoMMLinkNode.MMTypeOfLink = GeTypeOfLink.kkClassDiagramRelationship
                LoMMLinkNode.MMRelationType = LoParentRelationShipRow(KrosLib.Editors.xModDataSet.TableSysnames.Hierarchy.Columns.RelationType)
                LoMMLinkNode.SnapToNodeBorder = True
                LoMMLinkNode.AutoRoute = True
                LoMMLinkNode.Style = LinkStyle.Cascading
                fcDiagram.Links.Add(LoMMLinkNode)
            Next

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'performs actions before closing application
    'returns value - true = application can be closed otherwise false
    Private Function CanExitApplication() As Boolean
        Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModCloseFile)
        Return Execute(LoAction) = GeActionResult.kkOk
    End Function
    'gets all aMod files with unsaved versions
    Private Function GetAllAmodFilesWithUnsavedVersions() As Collection
        Dim LoAllAmodFilesWithUnsavedVersions As Collection = New Collection

        For Each LoDSaModFile As ClsDSaModFile In MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetCollection
            If GetAllUnsavedVersionsOfAmodFile(LoDSaModFile.Path).Count > 0 Then LoAllAmodFilesWithUnsavedVersions.Add(LoDSaModFile)
        Next

        Return LoAllAmodFilesWithUnsavedVersions
    End Function
    'gets all unsaved versions of aMod file
    Private Function GetAllUnsavedVersionsOfAmodFile(ByVal IsAmodFilePath As String) As Collection
        Dim LoAllUnsavedVersionsOfAmodFile As Collection = New Collection

        Dim LoDSaModFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(IsAmodFilePath)
        If LoDSaModFile IsNot Nothing Then
            For Each LoDDsAModOneVersion As ClsDsAModOneVersion In LoDSaModFile.OpenedEditableVersions.GetCollection
                If MoTabControl.GetTabClassDiagram(LoDSaModFile.Path, LoDDsAModOneVersion.GetVersionVID).ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.AmodVersion.WasModified Then
                    LoAllUnsavedVersionsOfAmodFile.Add(LoDDsAModOneVersion.GetVersionVID, LoDDsAModOneVersion.GetVersionVID) 'adding also key coz I will need it later
                End If
            Next
        End If

        Return LoAllUnsavedVersionsOfAmodFile
    End Function
    'gets if table column is PK or FK - used for ex. to prevent of changing PK or FK in panels
    Private Function IsTableColumnPKorFK(ByVal IoMMTableNode As ClsMMTableNode, ByVal IiRowIndex As Integer) As Boolean
        Try
            Dim LoDataTable As DataTable = AmodVersion.GetTableByAppTableName(IoMMTableNode.AppTableName)
            Dim LoRow As DataRow = AmodVersion.GetDataTableRowByColumnName(IoMMTableNode.AppTableName, IoMMTableNode.MMGetColumnNameByRowIndex(IiRowIndex))

            Return LoRow(KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.System) = KrosLib.Data.eSystemColumnType.Id Or LoRow(KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.System) = KrosLib.Data.eSystemColumnType.ForeignKey
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return True
        End Try
    End Function
    'fills MoUcnComboboxJoinedModule with all modules from aMod solution
    Public Function FillComboboxJoinedModule() As GeActionResult
        Try
            Dim LoTextCollection As Collection = New Collection
            Dim LoIdCollection As Collection = New Collection

            For Each LoRow As DataRow In MoDSaModSolutionFile.DSaModSolution.ModulesTable.Rows
                LoTextCollection.Add(LoRow(DsAmodSolution.ModulesSysnames.Columns.HumanModuleName))
                LoIdCollection.Add(LoRow(DsAmodSolution.ModulesSysnames.Columns.ModuleName))
            Next

            'adding empty string - allow to choose no module
            LoTextCollection.Add("-- Ziadny modul --")
            LoIdCollection.Add("")


            MoUcnComboboxJoinedModule = New UcnCombobox
            MoUcnComboboxJoinedModule.Init("Moduly aMod projektu", LoTextCollection, , LoIdCollection)

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'adds joined module
    Private Function AddJoinedModule(ByVal IsOriginalModuleName As String, ByVal IsJoinedModuleName As String) As GeActionResult
        Try
            Dim LoChildMMModuleNode As ClsMMModuleNode = GetModuleFromDiagramByModuleName(IsOriginalModuleName, fcDiagram)
            Dim LoJoinedMMModuleNode As ClsMMModuleNode = Nothing 'GetModuleFromDiagramByModuleName(IsJoinedModuleName, fcDiagram)
            Dim LoMMLinkNode As ClsMMLinkNode = Nothing

            LoMMLinkNode = GetJoinModuleRelationshipLinkAndJoinedModuleFromDiagramByChildModule(LoChildMMModuleNode, IsJoinedModuleName, fcDiagram, LoJoinedMMModuleNode)

            If LoMMLinkNode IsNot Nothing Then
                'link already exists
                LoMMLinkNode.Text = (CInt(LoMMLinkNode.Text) + 1).ToString
            Else
                'link doesnt exist
                LoJoinedMMModuleNode = GetModuleFromDiagramByModuleName(IsJoinedModuleName, fcDiagram)
                LoMMLinkNode = New ClsMMLinkNode(fcDiagram)
                LoMMLinkNode.MMTypeOfLink = GeTypeOfLink.kkJoinedModuleRelationship
                LoMMLinkNode.Text = "1"
                LoMMLinkNode.Origin = LoChildMMModuleNode
                LoMMLinkNode.Destination = LoJoinedMMModuleNode
                fcDiagram.Links.Add(LoMMLinkNode)
            End If

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'removes joined module
    Private Function RemoveJoinedModule(ByVal IsOriginalModuleName As String, ByVal IsJoinedModuleNameForRemove As String) As GeActionResult
        Try
            Dim LoChildMMModuleNode As ClsMMModuleNode = GetModuleFromDiagramByModuleName(IsOriginalModuleName, fcDiagram)
            Dim LoJoinedMMModuleNode As ClsMMModuleNode = Nothing 'GetModuleFromDiagramByModuleName(IsJoinedModuleName, fcDiagram)
            Dim LoMMLinkNode As ClsMMLinkNode = Nothing

            LoMMLinkNode = GetJoinModuleRelationshipLinkAndJoinedModuleFromDiagramByChildModule(LoChildMMModuleNode, IsJoinedModuleNameForRemove, fcDiagram, LoJoinedMMModuleNode)

            If LoMMLinkNode IsNot Nothing Then
                'link already exists
                LoMMLinkNode.Text = (CInt(LoMMLinkNode.Text) - 1).ToString
                If LoMMLinkNode.Text = "0" Then
                    'remove link
                    fcDiagram.Links.Remove(LoMMLinkNode)
                End If
            Else
                MessageBox.Show("Povodny vztah naviazania modulu " & IsOriginalModuleName & " na modul " & IsJoinedModuleNameForRemove & " nebol najdeny!", "Nenajdeny vztah naviazania", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return GeActionResult.kkError
            End If


            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'rename joined module of child modules
    Private Function RenameJoinedModuleOfChildModules(ByVal IsJoinedModuleOldName As String, ByVal IsJoinedModuleNewName As String) As GeActionResult
        Try
            Dim LeResult As GeActionResult = GeActionResult.kkOk
            Dim LoJoinedMMModuleNode As ClsMMModuleNode = GetModuleFromDiagramByModuleName(IsJoinedModuleOldName, MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram)

            Dim LoChildMMModuleNode As ClsMMModuleNode = Nothing
            For Each LoLink As ClsMMLinkNode In LoJoinedMMModuleNode.IncomingLinks
                LoChildMMModuleNode = CType(LoLink.Origin, ClsMMModuleNode)

                Dim LsAmodFilePath As String = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAmodFilePath(LoChildMMModuleNode.ModuleName)
                Dim LoDSaModFile As ClsDSaModFile = Nothing
                Dim LoDsAModOneVersion As ClsDsAModOneVersion = Nothing
                Dim LbCloseVersion As Boolean = False
                LoDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodFilePath, True)
                If LoDSaModFile Is Nothing Then
                    'aMod file is not opened - open it
                    LeResult = QuickOpenAmodFile(LsAmodFilePath, LoDSaModFile)
                End If

                If LoDSaModFile IsNot Nothing Then
                    'open version
                    LoDsAModOneVersion = LoDSaModFile.OpenedEditableVersions.GetItem(LoDSaModFile.Dat.GetLastVersion, True)
                    If LoDsAModOneVersion Is Nothing Then
                        LoDsAModOneVersion = LoDSaModFile.OpenVersion(LoDSaModFile.Dat.GetLastVersion, False)
                        LbCloseVersion = True
                    End If
                End If

                If LoDsAModOneVersion IsNot Nothing Then
                    'renaming old joined module in child modules
                    LoDsAModOneVersion.DSaModVersion.RenameJoinedModule(IsJoinedModuleOldName, IsJoinedModuleNewName)
                    'saving version and file
                    LoDSaModFile.SaveVersion(LoDSaModFile.Dat.GetLastVersion)
                    LoDSaModFile.SaveFile()
                    'close version if it was opened just for this purpose
                    If LbCloseVersion Then
                        LoDSaModFile.CloseVersion(LoDsAModOneVersion)
                    End If
                Else
                    Throw New Exception("Nepodarilo sa otvorit verziu pre zmenu nazvu naviazaneho modulu!")
                End If
            Next

            Return LeResult
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'refreshes links of child module according to last version - used after last version was changed (after promote, remove, import)
    Private Function RefreshJoinedModulesLinksOfChildModule(ByVal IsChildModuleName As String) As GeActionResult
        Try
            Dim LeResult As GeActionResult = GeActionResult.kkOk
            Dim LoChildMMModuleNode As ClsMMModuleNode = GetModuleFromDiagramByModuleName(IsChildModuleName, MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram)

            'removing old joined modules links
            For LiI As Integer = LoChildMMModuleNode.OutgoingLinks.Count - 1 To 0 Step -1
                Dim LoLink As ClsMMLinkNode = LoChildMMModuleNode.OutgoingLinks(LiI)
                MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram.Links.Remove(LoLink)
            Next

            'creating new joined modules links
            'open aMod file
            Dim LsAmodFilePath As String = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAmodFilePath(LoChildMMModuleNode.ModuleName)
            Dim LoDSaModFile As ClsDSaModFile = Nothing
            Dim LoDsAModOneVersion As ClsDsAModOneVersion = Nothing
            Dim LbCloseVersion As Boolean = False
            LoDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodFilePath, True)
            If LoDSaModFile Is Nothing Then
                'aMod file is not opened - open it
                LeResult = QuickOpenAmodFile(LsAmodFilePath, LoDSaModFile)
            End If

            If LoDSaModFile IsNot Nothing Then
                'open version
                LoDsAModOneVersion = LoDSaModFile.OpenedEditableVersions.GetItem(LoDSaModFile.Dat.GetLastVersion, True)
                If LoDsAModOneVersion Is Nothing Then
                    LoDsAModOneVersion = LoDSaModFile.OpenVersion(LoDSaModFile.Dat.GetLastVersion, False)
                    LbCloseVersion = True
                Else
                    'save version before creating new joined modules links
                    LoDSaModFile.SaveVersion(LoDsAModOneVersion.GetVersionVID)
                End If
            End If

            'create new joined modules links
            If LoDsAModOneVersion IsNot Nothing Then
                'If LoDsAModOneVersion IsNot Nothing Then
                Dim LoJoinedModules As Collection = LoDsAModOneVersion.GetAllJoinedModulesFromThisVersion()
                For Each LoJoinedModule As String In LoJoinedModules
                    LeResult = AddJoinedModule(IsChildModuleName, LoJoinedModule)
                    If LeResult <> GeActionResult.kkOk Then Exit For
                Next

                'save changes in aMod solution file
                Dim LoAction As ClsAction = New ClsAction(GeAction.kkaModSolutionSaveFile)
                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(LoAction)
                If LbCloseVersion Then
                    LoDSaModFile.CloseVersion(LoDsAModOneVersion)
                End If
            Else
                Throw New Exception("Nepodarilo sa otvorit verziu pre zmenu vztahov napojenych modulov!")
            End If

            Return LeResult
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'refreshes joined modules in modul - used after promoting version, deleting version, when some joined modules dont exists
    Private Function RefreshJoinedModulesInModule(ByVal IoDSaModFile As ClsDSaModFile) As GeActionResult
        Try
            Dim LeResult As GeActionResult = GeActionResult.kkOk
            Dim LoAllModules As Collection = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAllModuleNames
            Dim LbCloseVersion As Boolean = False

            'open version
            Dim LoDsAModOneVersion As ClsDsAModOneVersion = IoDSaModFile.OpenedEditableVersions.GetItem(IoDSaModFile.Dat.GetLastVersion, True)
            If LoDsAModOneVersion Is Nothing Then
                LoDsAModOneVersion = IoDSaModFile.OpenVersion(IoDSaModFile.Dat.GetLastVersion, False)
                LbCloseVersion = True
            End If

            'checking for existing modules in aMod solution
            For Each LoTableListRow As DataRow In LoDsAModOneVersion.GetAllDataTableRowsFromTableList
                For Each LoTableRow As DataRow In LoDsAModOneVersion.DSaModVersion.Tables(LoTableListRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.TableName)).Rows
                    If Not LoAllModules.Contains(LoTableRow(KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.JoinModuleID)) Then
                        'LoTableRow(KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.JoinModuleID) = ""
                        'call special settings for a row
                        LoDsAModOneVersion.DSaModVersion.SetJoinedModule("", LoTableRow, Nothing)
                    End If
                Next
            Next

            'saving version and file
            IoDSaModFile.SaveVersion(IoDSaModFile.Dat.GetLastVersion)
            IoDSaModFile.SaveFile()
            'close version if it was opened just for this purpose
            If LbCloseVersion Then
                IoDSaModFile.CloseVersion(LoDsAModOneVersion)
            End If

            Return LeResult
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'refreshes panel in main tab with table columns info joined to module - used after change of module name, human module name, unit name, human unit name, table name ect in any tab
    Private Function RefreshTableColumnsJoinedToModule(ByVal IsModuleName As String, ByVal IsUnitName As String, ByVal IsTableName As String, ByVal IsColumnName As String) As GeActionResult
        'it takes long time to refresh whole grid (opening aMod files + versions), so I check occurance of any item in grid directly in grid (in its rows)
        Try
            Dim LbWasMatch As Boolean = False
            For Each LoNode As DevExpress.XtraTreeList.Nodes.TreeListNode In MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.MoUcnJoinedModulesInfoUC.tlTreeList.Nodes
                If IsModuleName <> "" Then
                    LbWasMatch = LoNode("ModuleName") = IsModuleName
                End If

                If LbWasMatch And IsUnitName <> "" Then
                    LbWasMatch = LoNode("UnitName") = IsUnitName
                End If

                If LbWasMatch And IsTableName <> "" Then
                    LbWasMatch = LoNode("TableName") = IsTableName
                End If

                If LbWasMatch And IsColumnName <> "" Then
                    LbWasMatch = LoNode("ColumnName") = IsColumnName
                End If

                'if is needed to refresh grid
                If LbWasMatch Then
                    MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshSelectedItemProperties(MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram.ActiveItem, False)
                    Exit For
                End If
            Next

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'gets all table columns (rows) joined to this module from concrete module
    Private Function GetTableColumnsJoinedToModuleFromModule(ByVal IsJoinedModuleName As String, ByVal IsChildModuleName As String, ByVal IsChildHumanModuleName As String, ByRef OoTableColumnsJoinedToModule As Collection) As Collection
        Try
            Dim LeResult As GeActionResult = GeActionResult.kkOk
            Dim LsAmodFilePath As String = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAmodFilePath(IsChildModuleName)
            Dim LoDSaModFile As ClsDSaModFile = Nothing
            Dim LoDsAModOneVersion As ClsDsAModOneVersion = Nothing
            Dim LbCloseVersion As Boolean = False
            LoDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodFilePath, True)
            If LoDSaModFile Is Nothing Then
                'aMod file is not opened - open it
                LeResult = QuickOpenAmodFile(LsAmodFilePath, LoDSaModFile)
            End If

            If LoDSaModFile IsNot Nothing Then
                'open version
                LoDsAModOneVersion = LoDSaModFile.OpenedEditableVersions.GetItem(LoDSaModFile.Dat.GetLastVersion, True)
                If LoDsAModOneVersion Is Nothing Then
                    LoDsAModOneVersion = LoDSaModFile.OpenVersion(LoDSaModFile.Dat.GetLastVersion, True)
                    LbCloseVersion = True
                End If
            End If

            If LoDsAModOneVersion IsNot Nothing Then
                For Each LoTableListRow As DataRow In LoDsAModOneVersion.GetAllDataTableRowsFromTableList
                    For Each LoDataTableRow As DataRow In LoDsAModOneVersion.DSaModVersion.Tables(LoTableListRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.TableName)).Rows
                        If LoDataTableRow(KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.JoinModuleID) = IsJoinedModuleName Then
                            Dim LoItem As String() = {"", "", "", "", "", "", "", ""}
                            LoItem(0) = IsChildModuleName
                            LoItem(1) = IsChildHumanModuleName
                            LoItem(2) = LoTableListRow(AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName)
                            LoItem(3) = LoDsAModOneVersion.GetUnitListRowByUnitName(LoTableListRow(AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName))(AMod2.DsAModOneVersion.TableSysnames.Units.Columns.HumanUnitName)
                            LoItem(4) = LoTableListRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.AppTableName)
                            LoItem(5) = LoTableListRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.HumanTableName)
                            LoItem(6) = LoDataTableRow(KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.ColumnName)
                            LoItem(7) = LoDataTableRow(KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.ResValue)
                            OoTableColumnsJoinedToModule.Add(LoItem)
                        End If
                    Next
                Next

                'close version if it was opened just for this purpose
                If LbCloseVersion Then
                    LoDSaModFile.CloseVersion(LoDsAModOneVersion)
                End If
            Else
                Throw New Exception("Nepodarilo sa otvorit verziu pre zmenu nazvu naviazaneho modulu!")
            End If

            Return OoTableColumnsJoinedToModule
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return OoTableColumnsJoinedToModule
        End Try
    End Function
    'gets all table columns (rows) joined to this module from all modules
    Private Function GetTableColumnsJoinedToModuleFromAllModules(ByVal IsJoinedModuleName As String) As Collection
        Try
            Dim LoJoinedColumns As Collection = New Collection

            Dim LeResult As GeActionResult = GeActionResult.kkOk
            Dim LoJoinedMMModuleNode As ClsMMModuleNode = GetModuleFromDiagramByModuleName(IsJoinedModuleName, MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram)

            Dim LoChildMMModuleNode As ClsMMModuleNode = Nothing
            For Each LoLink As ClsMMLinkNode In LoJoinedMMModuleNode.IncomingLinks
                LoChildMMModuleNode = CType(LoLink.Origin, ClsMMModuleNode)
                GetTableColumnsJoinedToModuleFromModule(IsJoinedModuleName, LoChildMMModuleNode.ModuleName, LoChildMMModuleNode.Text, LoJoinedColumns)
            Next

            Return LoJoinedColumns
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return Nothing
        End Try
    End Function
    'quick opening of aMod file - used when i want to change only any data and not to open it within a tab
    Private Function QuickOpenAmodFile(ByVal IsAmodFilePath As String, ByRef OoDSaModFile As ClsDSaModFile) As GeActionResult
        Try
            'module name is only temporary coz Im not going to create new version but open version
            ''DOCASNE - stale sa teda vytvori nova verzia, co je zbytocne!!!
            Dim LeResult As GeActionResult = GeActionResult.kkOk
            OoDSaModFile = New ClsDSaModFile("TEMPORARYMODULE", "TEMPORARYMODULE")

            LeResult = OoDSaModFile.Init(IsAmodFilePath)
            If LeResult = GeActionResult.kkOk Then
                LeResult = OoDSaModFile.OpenFile
            End If

            Return LeResult
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
#End Region
#Region "Subs"
    'reflects primary operation of hand on form
    Private Sub ReflectPrimaryOperationOfHandOnForm(ByVal IeOldStatus As GePrimaryOperationOfHand)
        'if there is any secondary operation (ex. zoom) -> cancel it
        If MoHand.SecondaryOperation <> GeSecondaryOperationOfHand.kkIdle Then MoHand.SecondaryOperation = GeSecondaryOperationOfHand.kkIdle

        '' ''Me.fcDiagramView.ModificationStart = ModificationStart.AutoHandles
        '' ''Me.fcDiagramView.Behavior = Behavior.Custom
        ''DOCASNE'' ilbActions.SelectedIndex = MoHand.PrimaryOperation
    End Sub
    'reflects secondary operation of hand on form
    Private Sub ReflectSecondaryOperationOfHandOnForm(ByVal IeOldStatus As GeSecondaryOperationOfHand)
        'if there was zoom operation -> set back cursor
        If IeOldStatus = GeSecondaryOperationOfHand.kkZoom Then
            Me.fcDiagramView.PointerCursor = Cursors.Arrow
        End If

        Select Case MoHand.SecondaryOperation
            Case GeSecondaryOperationOfHand.kkIdle
                MoHand.PrimaryOperation = MoHand.PrimaryOperation
            Case GeSecondaryOperationOfHand.kkZoom
                Me.fcDiagramView.PointerCursor = New Cursor(Me.GetType(), "MagnGlassNORMAL.cur")
                Me.fcDiagramView.ModificationStart = ModificationStart.SelectedOnly
                Me.fcDiagramView.Behavior = Behavior.DrawShapes
        End Select
    End Sub
    'reflects type of link on form
    Private Sub ReflectTypeOfLink(ByVal IeOldTypeOfLink As Integer)
        If MoUcnRelationsUC IsNot Nothing Then MoUcnRelationsUC.SelectItemByData(MoHand.TypeOfLink)
        ' '' ''Select Case MoHand.TypeOfLink
        ' '' ''    Case KrosLib.Data.eRelationType.OneToZeroOrOne 'kkRelationTypes.kk_1_01
        ' '' ''        ilbRelationships.SelectedIndex = 0
        ' '' ''    Case KrosLib.Data.eRelationType.OneToOne 'kkRelationTypes.kk_1_1
        ' '' ''        ilbRelationships.SelectedIndex = 1
        ' '' ''    Case KrosLib.Data.eRelationType.OneToOneOrMore 'kkRelationTypes.kk_1_1n
        ' '' ''        ilbRelationships.SelectedIndex = 2
        ' '' ''    Case KrosLib.Data.eRelationType.OneToMany 'kkRelationTypes.kk_1_n
        ' '' ''        ilbRelationships.SelectedIndex = 3
        ' '' ''    Case Else
        ' '' ''        Debug.Print("CHYBA!!! - ReflectTypeOfLink")
        ' '' ''End Select
    End Sub
    'reflects canvas zoom factor
    Private Sub ReflectZoom()
        'rounding ZoomFactor to integer
        'fcDiagramView.ZoomFactor = Math.Round(fcDiagramView.ZoomFactor)
        barCboZoom.EditValue = fcDiagramView.ZoomFactor & "%"
        barEditZoom.EditValue = fcDiagramView.ZoomFactor / (1500 / RepositoryEditZoom.Maximum)
    End Sub
    'zooming canvas to point from screen coordinates
    Private Sub ZoomCanvasToPointFromCursor(ByVal IoPointFromScreen As Point, ByVal IiZoomFactor As Integer)
        Try
            'calculation point from screen to client and then from client to document
            Dim LoOldCursorPosition As PointF = fcDiagramView.ClientToDoc(fcDiagramView.PointToClient(IoPointFromScreen))
            'calculation zoom factor and zooming
            Dim LiZoomFactor As Integer = IIf(fcDiagramView.ZoomFactor + (IiZoomFactor / 30.0F) >= 25, fcDiagramView.ZoomFactor + (IiZoomFactor / 30.0F), 25)
            fcDiagramView.ZoomFactor = LiZoomFactor
            ReflectZoom()
            'scrolling after zoom
            Dim LoNewCursorPosition As PointF = fcDiagramView.ClientToDoc(fcDiagramView.PointToClient(Cursor.Position))
            Dim LnDeltaX As Single = (LoOldCursorPosition.X - LoNewCursorPosition.X)
            Dim LnDeltaY As Single = (LoOldCursorPosition.Y - LoNewCursorPosition.Y)
            ScrollCanvas(LnDeltaX, LnDeltaY)
        Catch ex As Exception
            LogEventFromException(ex, , )
        End Try
    End Sub
    'zooming canvas from known zoom factor (zooming to center of client canvas)
    Private Sub ZoomCanvasFromZoom(ByVal IiZoomFactor As Integer)
        Try
            'calculation center of client canvas (calculation from client to document)
            Dim LoOldCenterOfClientArea As PointF = fcDiagramView.ClientToDoc(CenterPointOfRectangle(fcDiagramView.ClientRectangle))
            'calculation zoom factor and zooming
            Dim LiZoomFactor As Integer = IIf(IiZoomFactor >= 25, IiZoomFactor, 25)
            fcDiagramView.ZoomFactor = LiZoomFactor
            ReflectZoom()
            'scrolling after zoom
            Dim LoNewCenterOfClientArea As PointF = fcDiagramView.ClientToDoc(CenterPointOfRectangle(fcDiagramView.ClientRectangle))
            Dim LnDeltaX As Single = (LoOldCenterOfClientArea.X - LoNewCenterOfClientArea.X)
            Dim LnDeltaY As Single = (LoOldCenterOfClientArea.Y - LoNewCenterOfClientArea.Y)
            ScrollCanvas(LnDeltaX, LnDeltaY)
        Catch ex As Exception
            LogEventFromException(ex, , )
        End Try
    End Sub
    'scrolling canvas
    Private Sub ScrollCanvas(ByVal InDeltaX As Single, ByVal InDeltaY As Single)
        Try
            fcDiagramView.ScrollTo(IIf(fcDiagramView.ScrollX + InDeltaX < 0, 0, fcDiagramView.ScrollX + InDeltaX), IIf(fcDiagramView.ScrollY + InDeltaY < 0, 0, fcDiagramView.ScrollY + InDeltaY))
        Catch ex As Exception
            LogEventFromException(ex, , )
        End Try
    End Sub
    'sets MbReadyForUse attribute and sets Enable property of usercontrol
    Private Sub SetReadyForUse(ByVal IbValue As Boolean)
        MbReadyForUse = IbValue
        Me.Enabled = IbValue 'enabling usercontrol
    End Sub
    'indicates if file was modified since last save - determines proper file: aMod version or MoDSaModSolutionFile
    Private Sub SetFileWasModified(ByVal IbWasModified As Boolean)
        Select Case MoTabPage.TypeOfTab
            Case GeTypeOfTab.kkNone
            Case GeTypeOfTab.kkMainTab
                MoDSaModSolutionFile.FileWasModified = IbWasModified
            Case GeTypeOfTab.kkClassDiagramTab
                AmodVersion.WasModified = IbWasModified
            Case GeTypeOfTab.kkUseCaseTab
                barBtnSaveUCDofModule.Enabled = IbWasModified
                'perform same things as in modified change event of MoAmodVersion etc.
                SetEnableMenuAfterChangeOfStateOfFile()
                MakeTabPageCaption()
            Case GeTypeOfTab.kkVersionComparisonTab
                'do nothing
        End Select
    End Sub
    'shows popup menu
    Private Sub ShowPopupMenu(ByVal IeTypeOfPopupMenu As GeTypeOfPopupMenu, ByVal IoPoint As Point)
        Select Case IeTypeOfPopupMenu
            Case GeTypeOfPopupMenu.kkNodeContext
                'xtrPopupMenuNodeContext.ShowPopup(IoPoint)
            Case GeTypeOfPopupMenu.kkUnitContext
                'xtrPopupMenuUnit.ShowPopup(IoPoint)
            Case Else
                Debug.Print("CHYBA!!! - ShowPopupMenu")
        End Select
    End Sub
    'setting dock panels settings before apllication starts
    Private Sub InitDockPanelsSettings(ByVal IoDockManager As DockManager, ByVal IoDockPanels As Collection)
        Try
            'setting dock manager
            MoDockManager = IoDockManager

            'setting docking panels
            MoDockPanelActions = IoDockPanels("DPACTIONS")
            MoDockPanelNotes = IoDockPanels("DPNOTES")
            MoDockPanelOverview = IoDockPanels("DPOVERVIEW")
            MoDockPanelProperties = IoDockPanels("DPPROPERTIES")
            MoDockPanelJoinedModulesInfo = IoDockPanels("DPJOINEDMODULES")
            MoDockPanelItemChanges = IoDockPanels("DPITEMCHANGES")
            MoDockPanelVersionsChanges = IoDockPanels("DPVERSIONSCHANGES")

            'ShowHideDockingPanels(False)

        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'refreshing properties of all parts of selected item (item, rows,...)
    Private Sub RefreshSelectedItemProperties(ByVal IoItem As DiagramItem, ByVal IbSynchroSelection As Boolean)
        Try
            fcDiagram.ActiveItem = IoItem
            MoUcnRTFeditorUC.ReadOnlyMode = False
            If MoTabPage.TypeOfTab = GeTypeOfTab.kkMainTab Then MoUcnJoinedModulesInfoUC.Init(Nothing)

            If IoItem IsNot Nothing Then
                Select Case IoItem.GetType.Name
                    Case "ClsMMTableNode"
                        Dim LoMMTableNode As ClsMMTableNode = CType(IoItem, ClsMMTableNode)

                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Trieda"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.GroupClientHeight = 45
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Expanded = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = LoMMTableNode.HighlightedRow <> -1
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Expanded = True

                        'refresh properties of item
                        MoUcnPropertiesOfItemUC.Init(LoMMTableNode)
                        'refresh properties of table rows
                        If LoMMTableNode.HighlightedRow <> -1 Then
                            Dim LoDataTable As DataTable = AmodVersion.GetTableByAppTableName(LoMMTableNode.AppTableName)
                            MoUcnPropertiesOfTableRowsUC.Init(LoMMTableNode, LoDataTable, MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.UcnComboboxJoinedModule, LoMMTableNode.HighlightedRow, True, Not MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab, Not IsTableColumnPKorFK(LoMMTableNode, LoMMTableNode.HighlightedRow) AndAlso Not MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab)
                        End If
                        'refresh RTF note
                        If LoMMTableNode.HighlightedRow = -1 Then
                            'table was clicked 
                            MoUcnRTFeditorUC.Init(AmodVersion.GetRTFdescriptionOfTable(LoMMTableNode.AppTableName))
                            'refresh comparison changes of table
                            If MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab Then
                                Dim LoRows As DataRow() = Nothing
                                Select Case MeSideOfCanvas
                                    Case GeSideOfCanvas.kkLeft
                                        LoRows = MoDSversionCompare.DsChanges.MainTable.Select(String.Format("{0}='{1}' and ({2}='{3}' or {4}='{5}')", AMod2.DsChanges.TableSysnames.Main.Columns.Location1, LoMMTableNode.AppTableName, AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "12", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "13"))
                                    Case GeSideOfCanvas.kkRight
                                        LoRows = MoDSversionCompare.DsChanges.MainTable.Select(String.Format("{0}='{1}' and ({2}='{3}' or {4}='{5}')", AMod2.DsChanges.TableSysnames.Main.Columns.Location1, LoMMTableNode.AppTableName, AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "11", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "13"))
                                End Select
                                Dim LsString As String = ""
                                For Each LoRow As DataRow In LoRows
                                    LsString = LsString + LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Description) + vbNewLine
                                Next
                                MoItemChangesMemoEdit.Text = LsString
                            End If
                        Else
                            'table cell was clicked
                            Dim LsColumnName As String
                            LsColumnName = LoMMTableNode.MMGetColumnNameByRowIndex(LoMMTableNode.HighlightedRow)
                            MoUcnRTFeditorUC.Init(AmodVersion.GetRTFdescriptionOfTableRow(LoMMTableNode.AppTableName, LsColumnName))
                            'refresh comparison changes of table column
                            If MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab Then
                                Dim LoRows As DataRow() = Nothing
                                Select Case MeSideOfCanvas
                                    Case GeSideOfCanvas.kkLeft
                                        LoRows = MoDSversionCompare.DsChanges.MainTable.Select(String.Format("{0}='{1}' and {2}='{3}' and ({4}='{5}' or {6}='{7}')", AMod2.DsChanges.TableSysnames.Main.Columns.Location1, LoMMTableNode.AppTableName, AMod2.DsChanges.TableSysnames.Main.Columns.Location2, LoMMTableNode.MMGetColumnNameByRowIndex(LoMMTableNode.HighlightedRow), AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "22", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "23"))
                                    Case GeSideOfCanvas.kkRight
                                        LoRows = MoDSversionCompare.DsChanges.MainTable.Select(String.Format("{0}='{1}' and {2}='{3}' and ({4}='{5}' or {6}='{7}')", AMod2.DsChanges.TableSysnames.Main.Columns.Location1, LoMMTableNode.AppTableName, AMod2.DsChanges.TableSysnames.Main.Columns.Location2, LoMMTableNode.MMGetColumnNameByRowIndex(LoMMTableNode.HighlightedRow), AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "21", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "23"))
                                End Select
                                Dim LsString As String = ""
                                For Each LoRow As DataRow In LoRows
                                    LsString = LsString + LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Description) + vbNewLine
                                Next
                                MoItemChangesMemoEdit.Text = LsString
                            End If
                        End If
                    Case "ClsMMLinkNode"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.GroupClientHeight = 25
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Expanded = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = False

                        Dim LoMMLinkNode As ClsMMLinkNode = CType(IoItem, ClsMMLinkNode)
                        Select Case LoMMLinkNode.MMTypeOfLink
                            Case GeTypeOfLink.kkClassDiagramRelationship
                                Select Case MoTabPage.TypeOfTab
                                    Case GeTypeOfTab.kkClassDiagramTab
                                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Vztah tried"
                                        'refresh properties of item
                                        MoUcnPropertiesOfItemUC.Init(LoMMLinkNode)
                                        'refresh RTF note
                                        Dim LoDestinationMMTableNode As ClsMMTableNode = CType(LoMMLinkNode.Destination, ClsMMTableNode)
                                        MoUcnRTFeditorUC.Init(AmodVersion.GetRTFdescriptionOfRelationship(LoDestinationMMTableNode.AppTableName))
                                    Case GeTypeOfTab.kkVersionComparisonTab
                                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Vztah tried"
                                        'refresh properties of item
                                        MoUcnPropertiesOfItemUC.Init(LoMMLinkNode)
                                        'refresh RTF note
                                        Dim LoDestinationMMTableNode As ClsMMTableNode = CType(LoMMLinkNode.Destination, ClsMMTableNode)
                                        MoUcnRTFeditorUC.Init(AmodVersion.GetRTFdescriptionOfRelationship(LoDestinationMMTableNode.AppTableName))
                                        'refresh comparison changes of relationship
                                        Dim LoMMOriginTableNode As ClsMMTableNode = LoMMLinkNode.Origin
                                        Dim LoMMDestinationTableNode As ClsMMTableNode = LoMMLinkNode.Destination

                                        Dim LoRows As DataRow() = Nothing
                                        Select Case MeSideOfCanvas
                                            Case GeSideOfCanvas.kkLeft
                                                LoRows = MoDSversionCompare.DsChanges.MainTable.Select(String.Format("{0}='{1}' and {2}='{3}'", AMod2.DsChanges.TableSysnames.Main.Columns.Location2, LoMMDestinationTableNode.AppTableName, AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "43"))
                                            Case GeSideOfCanvas.kkRight
                                                LoRows = MoDSversionCompare.DsChanges.MainTable.Select(String.Format("{0}='{1}' and ({2}='{3}' or {4}='{5}')", AMod2.DsChanges.TableSysnames.Main.Columns.Location2, LoMMDestinationTableNode.AppTableName, AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "41", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "43"))
                                        End Select
                                        Dim LsString As String = ""
                                        For Each LoRow As DataRow In LoRows
                                            LsString = LsString + LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Description) + vbNewLine
                                        Next
                                        MoItemChangesMemoEdit.Text = LsString
                                End Select
                            Case GeTypeOfLink.kkJoinedModuleRelationship
                                MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Napojene moduly"
                                'refresh properties of item
                                MoUcnPropertiesOfItemUC.Init(LoMMLinkNode)
                                'refresh joined modules info
                                MoUcnJoinedModulesInfoUC.Init(LoMMLinkNode)
                                MoUcnRTFeditorUC.ReadOnlyMode = True
                            Case GeTypeOfLink.kkUseCaseRelationship
                                MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Vztah"
                                'refresh properties of item
                                MoUcnPropertiesOfItemUC.Init(LoMMLinkNode)
                                'refresh RTF note
                                MoUcnRTFeditorUC.Init(LoMMLinkNode.Tag)
                            Case GeTypeOfLink.kkNote
                                MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Spojenie komentara"
                                'refresh properties of item
                                MoUcnPropertiesOfItemUC.Init(LoMMLinkNode)
                                'refresh RTF note
                                MoUcnRTFeditorUC.Init(LoMMLinkNode.Tag)
                        End Select
                    Case "ClsMMContainerNode"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Formular"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.GroupClientHeight = 45
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Expanded = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = False

                        Dim LoMMContainerNode As ClsMMContainerNode = CType(IoItem, ClsMMContainerNode)
                        'refresh properties of item
                        MoUcnPropertiesOfItemUC.Init(LoMMContainerNode)
                        'refresh RTF note
                        MoUcnRTFeditorUC.Init(AmodVersion.GetRTFdescriptionOfUnit(LoMMContainerNode.UnitName))
                        'refresh comparison changes of unit
                        If MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab Then
                            Dim LoRows As DataRow() = Nothing
                            Select Case MeSideOfCanvas
                                Case GeSideOfCanvas.kkLeft
                                    LoRows = MoDSversionCompare.DsChanges.MainTable.Select(String.Format("{0}='{1}' and ({2}='{3}' or {4}='{5}')", AMod2.DsChanges.TableSysnames.Main.Columns.Location1, LoMMContainerNode.UnitName, AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "32", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "33"))
                                Case GeSideOfCanvas.kkRight
                                    LoRows = MoDSversionCompare.DsChanges.MainTable.Select(String.Format("{0}='{1}' and ({2}='{3}' or {4}='{5}')", AMod2.DsChanges.TableSysnames.Main.Columns.Location1, LoMMContainerNode.UnitName, AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "31", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "33"))
                            End Select
                            Dim LsString As String = ""
                            For Each LoRow As DataRow In LoRows
                                LsString = LsString + LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Description) + vbNewLine
                            Next
                            MoItemChangesMemoEdit.Text = LsString
                        End If
                    Case "ClsMMModuleNode"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Modul"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.GroupClientHeight = 45
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Expanded = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = False

                        Dim LoMMModuleNode As ClsMMModuleNode = CType(IoItem, ClsMMModuleNode)
                        'refresh properties of item
                        MoUcnPropertiesOfItemUC.Init(LoMMModuleNode)
                        'refresh joined modules info
                        MoUcnJoinedModulesInfoUC.Init(LoMMModuleNode)
                        'refresh RTF note
                        MoUcnRTFeditorUC.Init(MoDSaModSolutionFile.GetRTFdescriptionOfModule(LoMMModuleNode.ModuleName))
                    Case "ClsMMActorNode"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Akter"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.GroupClientHeight = 25
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Expanded = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = False

                        Dim LoMMActorNode As ClsMMActorNode = CType(IoItem, ClsMMActorNode)
                        'refresh properties of item
                        MoUcnPropertiesOfItemUC.Init(LoMMActorNode)
                        'refresh RTF note
                        MoUcnRTFeditorUC.Init(IIf(LoMMActorNode.Tag Is Nothing, "", CStr(LoMMActorNode.Tag)))
                    Case "ClsMMActivityNode"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Aktivita"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.GroupClientHeight = 25
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Expanded = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = False

                        Dim LoMMActivityNode As ClsMMActivityNode = CType(IoItem, ClsMMActivityNode)
                        'refresh properties of item
                        MoUcnPropertiesOfItemUC.Init(LoMMActivityNode)
                        'refresh RTF note
                        MoUcnRTFeditorUC.Init(LoMMActivityNode.Tag)
                    Case "ClsMMSystemBoundaryNode"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Hranica"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.GroupClientHeight = 25
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Expanded = True
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = False

                        Dim LoMMSystemBoundaryNode As ClsMMSystemBoundaryNode = CType(IoItem, ClsMMSystemBoundaryNode)
                        'refresh properties of item
                        MoUcnPropertiesOfItemUC.Init(LoMMSystemBoundaryNode)
                        'refresh RTF note
                        MoUcnRTFeditorUC.Init(LoMMSystemBoundaryNode.Tag)
                    Case "ClsMMNoteNode"
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = False
                        MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = False

                        Dim LoMMNoteNode As ClsMMNoteNode = CType(IoItem, ClsMMNoteNode)
                        'refresh RTF note
                        MoUcnRTFeditorUC.Init(LoMMNoteNode.Text)
                        'refresh comparison changes of unit
                        If MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab Then
                            Dim LoRows As DataRow() = Nothing
                            Select Case MeSideOfCanvas
                                Case GeSideOfCanvas.kkLeft
                                    LoRows = MoDSversionCompare.DsChanges.MainTable.Select(String.Format("{0}='{1}' and ({2}='{3}' or {4}='{5}')", AMod2.DsChanges.TableSysnames.Main.Columns.NoteId, LoMMNoteNode.ID, AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "52", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "53"))
                                Case GeSideOfCanvas.kkRight
                                    LoRows = MoDSversionCompare.DsChanges.MainTable.Select(String.Format("{0}='{1}' and ({2}='{3}' or {4}='{5}')", AMod2.DsChanges.TableSysnames.Main.Columns.NoteId, LoMMNoteNode.ID, AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "51", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "53"))
                            End Select
                            Dim LsString As String = ""
                            For Each LoRow As DataRow In LoRows
                                LsString = LsString + LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Description) + vbNewLine
                            Next
                            MoItemChangesMemoEdit.Text = LsString
                        End If
                End Select
            Else
                Dim LbContinue As Boolean = False
                Select Case MoTabPage.TypeOfTab
                    Case GeTypeOfTab.kkClassDiagramTab, GeTypeOfTab.kkVersionComparisonTab
                        If MoDSaModFile IsNot Nothing AndAlso MoAmodVersion IsNot Nothing Then
                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = True
                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Modul"
                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = False

                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.GroupClientHeight = 65
                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Expanded = True

                            'refresh RTF note
                            MoUcnRTFeditorUC.Init(MoDSaModFile.GetRTFdescriptionOfVersion(AmodVersion.GetVersionVID))

                            LbContinue = True
                        End If
                    Case GeTypeOfTab.kkMainTab
                        If MoDSaModSolutionFile IsNot Nothing Then
                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = True
                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Caption = "Projekt"
                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = False

                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.GroupClientHeight = 25
                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Expanded = True

                            'refresh RTF note
                            MoUcnRTFeditorUC.Init(MoDSaModSolutionFile.GetRTFdescriptionOfSolution)

                            LbContinue = True
                        End If
                    Case GeTypeOfTab.kkUseCaseTab
                        If MoDSaModFile IsNot Nothing Then
                            MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = False
                            'refresh RTF note
                            MoUcnRTFeditorUC.Init(CStr(fcDiagram.Tag))

                            LbContinue = True
                        End If
                End Select

                If LbContinue = True Then
                    'refresh properties of item
                    MoUcnPropertiesOfItemUC.Init(Me) 'UcnDiagramCanvasBase
                Else
                    MoUcnDiagramCanvasAdvanced.nbgPropertiesOfItem.Visible = False
                    MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.Visible = False
                    ClearPanelsInfo()
                End If
            End If

            'try to select the same node withinm another UcnDiagramCanvasBase canvas in compare mode
            If MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab AndAlso IbSynchroSelection Then
                Select Case MeSideOfCanvas
                    Case GeSideOfCanvas.kkLeft
                        If MoRightCanvasBase IsNot Nothing Then MoRightCanvasBase.RefreshSynchroSelectedItemProperties(fcDiagram.ActiveItem)
                    Case GeSideOfCanvas.kkRight
                        If MoLeftCanvasBase IsNot Nothing Then MoLeftCanvasBase.RefreshSynchroSelectedItemProperties(fcDiagram.ActiveItem)
                End Select
            End If
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'synchro refreshing properties of all parts of selected item (item, rows,...) in compare mode. Ill try to select the same node withinm another UcnDiagramCanvasBase canvas
    Public Function RefreshSynchroSelectedItemProperties(ByVal IoSelectedNodeInAnotherCanvas As DiagramItem) As GeActionResult
        Try
            Dim LsOriginalNodeID As String = ""
            Dim LiHighlightedRowID As Integer = -1 'highlighted row of original table
            'get original node ID from another canvas
            If IoSelectedNodeInAnotherCanvas IsNot Nothing Then
                Select Case IoSelectedNodeInAnotherCanvas.GetType.Name
                    Case "ClsMMContainerNode"
                        Dim LoMMContainerNode As ClsMMContainerNode = CType(IoSelectedNodeInAnotherCanvas, ClsMMContainerNode)
                        LsOriginalNodeID = LoMMContainerNode.ID
                    Case "ClsMMTableNode"
                        Dim LoMMTableNode As ClsMMTableNode = CType(IoSelectedNodeInAnotherCanvas, ClsMMTableNode)
                        LsOriginalNodeID = LoMMTableNode.ID
                        LiHighlightedRowID = LoMMTableNode.MMGetColumnIDByRowIndex(LoMMTableNode.HighlightedRow)
                    Case "ClsMMLinkNode"
                        Dim LoMMLinkNode As ClsMMLinkNode = CType(IoSelectedNodeInAnotherCanvas, ClsMMLinkNode)
                        LsOriginalNodeID = LoMMLinkNode.ID
                    Case "ClsMMNoteNode"
                        Dim LoMMNoteNode As ClsMMNoteNode = CType(IoSelectedNodeInAnotherCanvas, ClsMMNoteNode)
                        LsOriginalNodeID = LoMMNoteNode.ID
                    Case "ClsMMModuleNode"
                        Dim LoMMModuleNode As ClsMMModuleNode = CType(IoSelectedNodeInAnotherCanvas, ClsMMModuleNode)
                        LsOriginalNodeID = LoMMModuleNode.ID
                    Case Else
                        Debug.Print("Neznamy typ node!")
                End Select
            End If

            'find node in this canvas with same ID
            Dim LoNode As DiagramItem = Nothing
            If LsOriginalNodeID <> "" Then
                LoNode = GetNodeFromDiagramByID(LsOriginalNodeID, fcDiagram)
            End If

            If LoNode IsNot Nothing AndAlso LoNode.GetType.Name = "ClsMMTableNode" Then
                Dim LoMMTableNode As ClsMMTableNode = CType(LoNode, ClsMMTableNode)
                LoMMTableNode.HighlightedRow = LoMMTableNode.MMGetRowIndexByColumnID(LiHighlightedRowID)
            End If

            'select node
            RefreshSelectedItemProperties(LoNode, False)

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'clear diagram items and properties panels info
    Private Sub ClearAllComponents()
        Me.fcDiagram.ClearAll()
        ClearPanelsInfo()
    End Sub
    'clear properties panels info
    Private Sub ClearPanelsInfo()
        MoUcnPropertiesOfItemUC.Clear()
        MoUcnPropertiesOfTableRowsUC.Clear()
        MoUcnRTFeditorUC.Clear()
    End Sub
    'set enable/disable values for everything :-) and perform another actions (caption of form,...)
    Private Sub SetAfterChangeOfStateOfFile()
        'setting caption of form
        MakeCaptionOfForm()
        'setting tab page supertip
        MakeTabPageSuperTip()
        'makes tab page caption
        MakeTabPageCaption()
        'menu items
        SetEnableMenuAfterChangeOfStateOfFile()
        'desktop items (panels,...)
        SetEnableControlsAfterChangeOfStateOfFile()
    End Sub
    'set enable/disable values for menu and toolbar after change of state of file
    Private Sub SetEnableMenuAfterChangeOfStateOfFile()
        Try
            Select Case MoTabPage.TypeOfTab
                Case GeTypeOfTab.kkNone
                    Throw New Exception
                Case GeTypeOfTab.kkMainTab
                    Dim LbFileOpened As Boolean = MoDSaModSolutionFile IsNot Nothing AndAlso ((MoDSaModSolutionFile.StateOfFile = GeFileState.kkOpened) Or (MoDSaModSolutionFile.StateOfFile = GeFileState.kkNewFile))

                    'open solution menu item
                    barBtnOpenSolution.Enabled = True
                    'save solution menu item
                    barBtnSaveSolution.Enabled = IIf(LbFileOpened, LbFileOpened AndAlso MoDSaModSolutionFile.FileWasModified, False)
                    'close solution menu item
                    barBtnCloseSolution.Enabled = LbFileOpened
                    'generating project menu item
                    barBtnExportAmodSolutionToProject.Enabled = LbFileOpened
                    'opening aMod solution file
                    barBtnOpenTargetSolution.Enabled = LbFileOpened
                Case GeTypeOfTab.kkClassDiagramTab
                    Dim LbFileOpened As Boolean = MoDSaModFile IsNot Nothing AndAlso ((MoDSaModFile.StateOfFile = GeFileState.kkOpened) Or (MoDSaModFile.StateOfFile = GeFileState.kkNewFile))

                    'save module menu item
                    barBtnSaveModule.Enabled = IIf(LbFileOpened, LbFileOpened AndAlso AmodVersion.WasModified, False)
                Case GeTypeOfTab.kkUseCaseTab
                    Dim LbFileOpened As Boolean = MoDSaModFile IsNot Nothing AndAlso ((MoDSaModFile.StateOfFile = GeFileState.kkOpened) Or (MoDSaModFile.StateOfFile = GeFileState.kkNewFile))

                    'save UCD menu item
                    barBtnSaveUCDofModule.Enabled = IIf(LbFileOpened, LbFileOpened AndAlso barBtnSaveUCDofModule.Enabled, False)
            End Select

        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'set enable/disable values for usercontrol after change of state of file
    Private Sub SetEnableControlsAfterChangeOfStateOfFile()
        Try
            Dim LbFileInitialized As Boolean
            Select Case MoTabPage.TypeOfTab
                Case GeTypeOfTab.kkNone
                    Throw New Exception
                Case GeTypeOfTab.kkMainTab
                    If MoDSaModSolutionFile IsNot Nothing Then
                        LbFileInitialized = (MoDSaModSolutionFile.StateOfFile = GeFileState.kkOpened) Or (MoDSaModSolutionFile.StateOfFile = GeFileState.kkNewFile)
                    Else
                        LbFileInitialized = False
                    End If

                    Try
                        MoDockPanelActions.Show()
                        barCheckItemPanelActions.Checked = True
                        MoDockPanelJoinedModulesInfo.Show()
                        barCheckItemPanelJoinedModulesInfo.Checked = True
                        MoDockPanelNotes.Show()
                        barCheckItemPanelNotes.Checked = True
                        MoDockPanelOverview.Show()
                        barCheckItemPanelOverview.Checked = True
                        MoDockPanelProperties.Show()
                        barCheckItemPanelProperties.Checked = True

                        MoDockPanelItemChanges.Close()
                        barCheckItemPanelItemChanges.Checked = False
                        barCheckItemPanelItemChanges.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                        MoDockPanelVersionsChanges.Close()
                        barCheckItemPanelVersionsChanges.Checked = False
                        barCheckItemPanelVersionsChanges.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    Catch ex As Exception

                    End Try

                    'enables or disables controls
                    EnableDisableDockingPanels(LbFileInitialized)
                    'enables or disables this canvas, but menu is always enabled!
                    EnableDisableCanvasBaseSpecial(LbFileInitialized)
                Case GeTypeOfTab.kkClassDiagramTab, GeTypeOfTab.kkUseCaseTab
                    If MoDSaModFile IsNot Nothing Then
                        LbFileInitialized = (MoDSaModFile.StateOfFile = GeFileState.kkOpened) Or (MoDSaModFile.StateOfFile = GeFileState.kkNewFile)
                    Else
                        LbFileInitialized = False
                    End If

                    Try
                        MoDockPanelActions.Show()
                        barCheckItemPanelActions.Checked = True
                        MoDockPanelNotes.Show()
                        barCheckItemPanelNotes.Checked = True
                        MoDockPanelOverview.Show()
                        barCheckItemPanelOverview.Checked = True
                        MoDockPanelProperties.Show()
                        barCheckItemPanelProperties.Checked = True

                        MoDockPanelJoinedModulesInfo.Close()
                        barCheckItemPanelJoinedModulesInfo.Checked = False
                        barCheckItemPanelJoinedModulesInfo.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                        MoDockPanelItemChanges.Close()
                        barCheckItemPanelItemChanges.Checked = False
                        barCheckItemPanelItemChanges.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                        MoDockPanelVersionsChanges.Close()
                        barCheckItemPanelVersionsChanges.Checked = False
                        barCheckItemPanelVersionsChanges.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    Catch ex As Exception

                    End Try

                    'enables or disables controls
                    EnableDisableDockingPanels(LbFileInitialized)
                    'enables or disables this canvas, but menu is always enabled!
                    EnableDisableCanvasBaseSpecial(LbFileInitialized)
                Case GeTypeOfTab.kkVersionComparisonTab
                    If MoDSaModFile IsNot Nothing Then
                        LbFileInitialized = (MoDSaModFile.StateOfFile = GeFileState.kkOpened) Or (MoDSaModFile.StateOfFile = GeFileState.kkNewFile)
                    Else
                        LbFileInitialized = False
                    End If

                    Try
                        MoDockPanelNotes.Show()
                        barCheckItemPanelNotes.Checked = True
                        MoDockPanelOverview.Show()
                        barCheckItemPanelOverview.Checked = True
                        MoDockPanelProperties.Show()
                        barCheckItemPanelProperties.Checked = True
                        MoDockPanelItemChanges.Show()
                        barCheckItemPanelItemChanges.Checked = True
                        MoDockPanelVersionsChanges.Show()
                        barCheckItemPanelVersionsChanges.Checked = True

                        MoDockPanelActions.Close()
                        barCheckItemPanelActions.Checked = False
                        barCheckItemPanelActions.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                        MoDockPanelJoinedModulesInfo.Close()
                        barCheckItemPanelJoinedModulesInfo.Checked = False
                        barCheckItemPanelJoinedModulesInfo.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    Catch ex As Exception

                    End Try

                    MoDockPanelNotes.Enabled = LbFileInitialized
                    MoUcnRTFeditorUC.ReadOnlyMode = True
                    MoDockPanelOverview.Enabled = LbFileInitialized
                    MoDockPanelProperties.Enabled = LbFileInitialized

                    'enables or disables this canvas, but menu is always enabled!
                    EnableDisableCanvasBaseSpecial(LbFileInitialized)
            End Select

        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'setting settings and optionally also visibility of some controls after init of control
    Public Sub SetAfterInit(Optional ByVal IbClearSelectedItem As Boolean = True)
        Try
            Select Case MoTabPage.TypeOfTab
                Case GeTypeOfTab.kkMainTab
                    rpModule.Visible = False
                    rpUseCaseDiagram.Visible = False
                    rpVersionsManagement.Visible = False
                    Me.fcDiagram.BackBrush = New SolidBrush(Color.LightGoldenrodYellow)
                Case GeTypeOfTab.kkClassDiagramTab
                    rpSolution.Visible = False
                    rpUseCaseDiagram.Visible = False
                    Me.fcDiagram.BackBrush = New SolidBrush(Color.LightSteelBlue)
                Case GeTypeOfTab.kkUseCaseTab
                    rpSolution.Visible = False
                    rpModule.Visible = False
                    rpVersionsManagement.Visible = False
                    Me.fcDiagram.BackBrush = New SolidBrush(Color.FromArgb(193, 241, 189))
                Case GeTypeOfTab.kkVersionComparisonTab
                    'here I set also true values coz of special situation on kkVersionComparisonTab tab - theres visible also ribbon menu on ucnDiagramCanvasBaseUC. See MergeRibbonMenuOfTab method of UcnTabControl class
                    rpSolution.Visible = False
                    rpModule.Visible = True
                    barBtnSaveModule.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    rpUseCaseDiagram.Visible = False
                    rpView.Visible = True
                    rpVersionsManagement.Visible = True
                    barBtnPromoteVersion.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
                    rpgModuleExport.Visible = False
                    rpgModuleImport.Visible = False
                    Me.fcDiagram.BackBrush = New SolidBrush(Color.LightSteelBlue)
            End Select

            'setting active item of diagram to nothing = nothing is selected!
            If IbClearSelectedItem Then
                fcDiagram.ActiveItem = Nothing
                RefreshSelectedItemProperties(Nothing, True)
            End If
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'set enable/disable values for ribbon and diagram
    Private Sub EnableDisableCanvasBaseSpecial(ByVal IbEnable As Boolean)
        fcDiagramView.Enabled = IbEnable
        xtrRibbonStatusBar.Enabled = IbEnable
    End Sub
    ' ''shows/hides all docking panels
    ''Private Sub ShowHideDockingPanels(ByVal IbVisibleDockPanels As Boolean)
    ''    '!!! panel with notes should be first because there are GotFocus and LostFocus events causing flashing effect
    ''    barCheckItemPanelNotes.Checked = IbVisibleDockPanels
    ''    barCheckItemPanelActions.Checked = IbVisibleDockPanels
    ''    barCheckItemPanelOverview.Checked = IbVisibleDockPanels
    ''    barCheckItemPanelProperties.Checked = IbVisibleDockPanels

    ''    '' ''barCheckItemPanelNotes_CheckedChanged(Nothing, Nothing)
    ''    '' ''barCheckItemPanelActions_CheckedChanged(Nothing, Nothing)
    ''    '' ''barCheckItemPanelOverview_CheckedChanged(Nothing, Nothing)
    ''    '' ''barCheckItemPanelProperties_CheckedChanged(Nothing, Nothing)
    ''End Sub
    'focuses fcDiagramView
    Private Sub FocusDiagramView()
        fcDiagramView.Focus()
    End Sub
    'setting some temporary settings coz of fuck ups from DevX side :-(
    Private Sub SetTemporarySettings()
        For Each LoRepositoryItem As DevExpress.XtraEditors.Repository.RepositoryItem In xtrRibbonControl.RepositoryItems
            'LoRepositoryItem.Appearance.BackColor = Color.Transparent
            'LoRepositoryItem.AppearanceDisabled.BackColor = Color.Transparent
            'LoRepositoryItem.AppearanceFocused.BackColor = Color.Transparent
            'LoRepositoryItem.AppearanceReadOnly.BackColor = Color.Transparent
            'LoRepositoryItem.AllowFocused = False
        Next
    End Sub
    'setting some default new settings of canvas (Diagram and DiagramView) which can be edited by user
    Private Sub SetDefaultNewSettingsOfCanvas()
        Try
            Me.fcDiagram.ShowGrid = False
            Me.fcDiagram.GridStyle = GridStyle.Lines
            Me.fcRuler.HorizontalScaleVisible = True
            Me.fcRuler.VerticalScaleVisible = True
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'reflects settings of canvas
    Private Sub ReflectCanvasSettings()
        Try
            barCheckShowGrid.EditValue = Me.fcDiagram.ShowGrid
            barCboTypeOfGrid.EditValue = IIf(Me.fcDiagram.GridStyle = GridStyle.Lines, "Ciary", "Bodky")
            barCheckShowHorizontalRuler.EditValue = Me.fcRuler.HorizontalScaleVisible
            barCheckShowVerticalRuler.EditValue = Me.fcRuler.VerticalScaleVisible
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'enables/disables all docking panels
    Private Sub EnableDisableDockingPanels(ByVal IbEnableDockPanels As Boolean)
        MoDockPanelActions.Enabled = IbEnableDockPanels
        MoDockPanelNotes.Enabled = IbEnableDockPanels
        MoDockPanelOverview.Enabled = IbEnableDockPanels
        MoDockPanelProperties.Enabled = IbEnableDockPanels
    End Sub
    'makes caption of form
    Public Sub MakeCaptionOfForm()
        Try
            If MoTabPage.TypeOfTab = GeTypeOfTab.kkMainTab Then
                If MoDSaModSolutionFile IsNot Nothing Then
                    Select Case MoDSaModSolutionFile.StateOfFile
                        Case GeFileState.kkOpened
                            frmMainForm.Text = "Projekt """ & MoDSaModSolutionFile.GetSolutionName & """ [" & MoDSaModSolutionFile.Path & "]"
                        Case Else
                            Throw New Exception("SetCaptionOfForm")
                    End Select
                    MoTabPage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.True
                Else
                    frmMainForm.Text = "-- Neinicializovany projekt --"
                    MoTabPage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.False
                End If
            End If
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'makes tab page supertip
    Public Sub MakeTabPageSuperTip()
        Try
            Dim LoSuperTip As DevExpress.Utils.SuperToolTip = New DevExpress.Utils.SuperToolTip
            Dim LsTabPageCaption As String = ""

            LoSuperTip.AllowHtmlText = DevExpress.Utils.DefaultBoolean.True
            LoSuperTip.DistanceBetweenItems = 1
            LoSuperTip.FixedTooltipWidth = False
            LoSuperTip.MaxWidth = 500

            Select Case MoTabPage.TypeOfTab
                Case GeTypeOfTab.kkMainTab
                    If MoDSaModSolutionFile IsNot Nothing AndAlso (MoDSaModSolutionFile.StateOfFile = GeFileState.kkNewFile Or MoDSaModSolutionFile.StateOfFile = GeFileState.kkOpened) Then
                        Dim LsSolutionName As String = MoDSaModSolutionFile.GetSolutionName
                        Dim LsSolutionFilePath As String = MoDSaModSolutionFile.Path

                        'solution name
                        LoSuperTip.Items.Add("Projekt:  ""<b>" & LsSolutionName & "</b>""")
                        'path to solution file
                        LoSuperTip.Items.Add("Cesta: ""<i>" & LsSolutionFilePath & "</i>""")
                    Else
                        '' ''solution name
                        ' ''LoSuperTip.Items.Add("Projekt:  ""<b>???</b>""")
                        '' ''path to solution file
                        ' ''LoSuperTip.Items.Add("Cesta: ""<i>???</i>""")
                    End If
                Case GeTypeOfTab.kkClassDiagramTab
                    If MoDSaModFile IsNot Nothing AndAlso AmodVersion.GetVersionVID <> -1 AndAlso (MoDSaModFile.StateOfFile = GeFileState.kkNewFile Or MoDSaModFile.StateOfFile = GeFileState.kkOpened) Then
                        Dim LsModuleName As String = MoDSaModFile.GetLastVersionModuleName()
                        Dim LsVID As String = AmodVersion.GetVersionVID.ToString
                        Dim LsAmodFilePath As String = MoDSaModFile.Path

                        'module name
                        LoSuperTip.Items.Add("Modul: ""<b>" & LsModuleName & "</b>""")
                        'version
                        LoSuperTip.Items.Add("Verzia: <b>" & LsVID & "</b>")
                        'path to aMod file
                        LoSuperTip.Items.Add("Cesta: ""<i>" & LsAmodFilePath & "</i>""")
                    Else
                        'module name
                        LoSuperTip.Items.Add("Modul: ""<b>...</b>""")
                        'version
                        LoSuperTip.Items.Add("Verzia: <b>...</b>")
                        'path to aMod file
                        LoSuperTip.Items.Add("Cesta: ""<i>...</i>""")
                    End If
                Case GeTypeOfTab.kkUseCaseTab
                    If MoDSaModFile IsNot Nothing AndAlso (MoDSaModFile.StateOfFile = GeFileState.kkNewFile Or MoDSaModFile.StateOfFile = GeFileState.kkOpened) Then
                        Dim LsModuleName As String = MoDSaModFile.GetLastVersionModuleName()
                        Dim LsAmodFilePath As String = MoDSaModFile.Path

                        'module name
                        LoSuperTip.Items.Add("Modul: ""<b>" & LsModuleName & "</b>""")
                        'path to aMod file
                        LoSuperTip.Items.Add("Cesta: ""<i>" & LsAmodFilePath & "</i>""")
                    Else
                        'module name
                        LoSuperTip.Items.Add("Modul: ""<b>...</b>""")
                        'path to aMod file
                        LoSuperTip.Items.Add("Cesta: ""<i>...</i>""")
                    End If
                Case GeTypeOfTab.kkVersionComparisonTab
                    If MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile IsNot Nothing AndAlso MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.AmodVersion.GetVersionVID <> -1 AndAlso (MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile.StateOfFile = GeFileState.kkNewFile Or MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile.StateOfFile = GeFileState.kkOpened) _
               AndAlso MoTabPage.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile IsNot Nothing AndAlso MoTabPage.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.AmodVersion.GetVersionVID <> -1 AndAlso (MoTabPage.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile.StateOfFile = GeFileState.kkNewFile Or MoTabPage.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile.StateOfFile = GeFileState.kkOpened) Then
                        Dim LoDSaModFile As ClsDSaModFile = MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile
                        Dim LoDsAModOneVersion As ClsDsAModOneVersion = MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.AmodVersion

                        Dim LsHumanModuleName As String = LoDSaModFile.GetLastVersionHumanModuleName()
                        Dim LsLeftVID As String = LoDsAModOneVersion.GetVersionVID.ToString
                        Dim LsRightVID As String = LoDsAModOneVersion.GetVersionVID.ToString
                        Dim LsAmodFilePath As String = LoDSaModFile.Path

                        'module name
                        LoSuperTip.Items.Add("Modul: ""<b>" & LsHumanModuleName & "</b>""")
                        'version
                        LoSuperTip.Items.Add("Porovnanie verzii: <b>" & LsLeftVID & ", " & LsRightVID & "</b>")
                        'path to aMod file
                        LoSuperTip.Items.Add("Cesta: ""<i>" & LsAmodFilePath & "</i>""")
                    Else
                        'module name
                        LoSuperTip.Items.Add("Modul: ""<b>...</b>""")
                        'version
                        LoSuperTip.Items.Add("Porovnanie verzii: <b>...</b>")
                        'path to aMod file
                        LoSuperTip.Items.Add("Cesta: ""<i>...</i>""")
                    End If
            End Select
            MoTabPage.SuperTip = LoSuperTip
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'makes tab page caption
    Public Sub MakeTabPageCaption()
        Try
            Dim LsTabPageCaption As String = ""
            Select Case MoTabPage.TypeOfTab
                Case GeTypeOfTab.kkMainTab
                    If MoDSaModSolutionFile IsNot Nothing AndAlso (MoDSaModSolutionFile.StateOfFile = GeFileState.kkNewFile Or MoDSaModSolutionFile.StateOfFile = GeFileState.kkOpened) Then
                        Dim LsSolutionName As String = MoDSaModSolutionFile.GetSolutionName
                        Dim LsWasModified As String = IIf(MoDSaModSolutionFile.FileWasModified, " *", "")
                        LsTabPageCaption = LsSolutionName & LsWasModified
                    Else
                        LsTabPageCaption = "-- Neinicializovany projekt --"
                    End If
                Case GeTypeOfTab.kkClassDiagramTab
                    If MoDSaModFile IsNot Nothing AndAlso AmodVersion.GetVersionVID <> -1 AndAlso (MoDSaModFile.StateOfFile = GeFileState.kkNewFile Or MoDSaModFile.StateOfFile = GeFileState.kkOpened) Then
                        Dim LsModuleName As String = MoDSaModFile.GetLastVersionHumanModuleName()
                        Dim LiVID As Integer = AmodVersion.GetVersionVID
                        Dim LiLastVersion As Integer = MoDSaModFile.Dat.GetLastVersion
                        Dim LsVersion As String = IIf(LiVID = LiLastVersion, "", " (" & LiVID.ToString & ")")
                        'Dim LsVersion As String = IIf(LiVID = LiLastVersion, "", " (!)")
                        Dim LsWasModified As String = IIf(AmodVersion.WasModified, " *", "")
                        LsTabPageCaption = LsModuleName & LsVersion & LsWasModified & ""
                    Else
                        LsTabPageCaption = "..."
                    End If
                Case GeTypeOfTab.kkUseCaseTab
                    If MoDSaModFile IsNot Nothing AndAlso (MoDSaModFile.StateOfFile = GeFileState.kkNewFile Or MoDSaModFile.StateOfFile = GeFileState.kkOpened) Then
                        Dim LsModuleName As String = MoDSaModFile.GetLastVersionHumanModuleName()
                        Dim LsWasModified As String = IIf(barBtnSaveUCDofModule.Enabled, " *", "")
                        LsTabPageCaption = LsModuleName & LsWasModified & ""
                    Else
                        LsTabPageCaption = "..."
                    End If
                Case GeTypeOfTab.kkVersionComparisonTab
                    If MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile IsNot Nothing AndAlso MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.AmodVersion.GetVersionVID <> -1 AndAlso (MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile.StateOfFile = GeFileState.kkNewFile Or MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile.StateOfFile = GeFileState.kkOpened) _
                  AndAlso MoTabPage.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile IsNot Nothing AndAlso MoTabPage.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.AmodVersion.GetVersionVID <> -1 AndAlso (MoTabPage.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile.StateOfFile = GeFileState.kkNewFile Or MoTabPage.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile.StateOfFile = GeFileState.kkOpened) Then
                        Dim LoDSaModFile As ClsDSaModFile = MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile
                        Dim LoLeftDsAModOneVersion As ClsDsAModOneVersion = MoTabPage.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.AmodVersion
                        Dim LoRightDsAModOneVersion As ClsDsAModOneVersion = MoTabPage.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.AmodVersion

                        Dim LsHumanModuleName As String = LoDSaModFile.GetLastVersionHumanModuleName()
                        Dim LsLeftVID As String = LoLeftDsAModOneVersion.GetVersionVID.ToString
                        Dim LsRightVID As String = LoRightDsAModOneVersion.GetVersionVID.ToString

                        LsTabPageCaption = LsHumanModuleName & ": " & LsLeftVID & " <--> " & LsRightVID
                    Else
                        LsTabPageCaption = "..."
                    End If
            End Select
            MoTabPage.Text = LsTabPageCaption
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'refresh captions and tips of tabs with opened versions from aMod file
    Private Sub RefreshCaptionAndTipOfTabsOfAmodFile(ByVal IsAmodFilePath As String)
        Try
            For Each LoTab As ClsUcnTabPage In MoTabControl.tcTabControl.TabPages
                Select Case LoTab.TypeOfTab
                    Case GeTypeOfTab.kkClassDiagramTab, GeTypeOfTab.kkUseCaseTab
                        If LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile.Path = IsAmodFilePath Then
                            LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageCaption()
                            LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageSuperTip()
                        End If
                    Case GeTypeOfTab.kkVersionComparisonTab
                        If LoTab.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModFile.Path = IsAmodFilePath Then
                            LoTab.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageCaption()
                            LoTab.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageSuperTip()
                            LoTab.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageCaption()
                            LoTab.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageSuperTip()
                        End If
                End Select
            Next
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'refresh captions and tips of all tabs
    Private Sub RefreshCaptionAndTipOfAllTabs()
        Try
            For Each LoTab As ClsUcnTabPage In MoTabControl.tcTabControl.TabPages
                Select Case LoTab.TypeOfTab
                    Case GeTypeOfTab.kkMainTab, GeTypeOfTab.kkClassDiagramTab, GeTypeOfTab.kkUseCaseTab
                        LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageCaption()
                        LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageSuperTip()
                    Case GeTypeOfTab.kkVersionComparisonTab
                        LoTab.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageCaption()
                        LoTab.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageSuperTip()
                        LoTab.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageCaption()
                        LoTab.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.MakeTabPageSuperTip()
                End Select
            Next
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
    'refresh selected items of all tabs
    Private Sub RefreshSelectedItemsOfAllTabs()
        Try
            For Each LoTab As ClsUcnTabPage In MoTabControl.tcTabControl.TabPages
                Select Case LoTab.TypeOfTab
                    Case GeTypeOfTab.kkMainTab, GeTypeOfTab.kkClassDiagramTab, GeTypeOfTab.kkUseCaseTab
                        'theres problem when I refresh selected item in diagram of tab where Im actually changing datat in grid, so I must skip actual selected tab
                        If Not MoTabControl.tcTabControl.SelectedTabPage.Equals(LoTab) Then LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshSelectedItemProperties(LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram.ActiveItem, False)
                    Case GeTypeOfTab.kkVersionComparisonTab
                        LoTab.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshSelectedItemProperties(LoTab.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram.ActiveItem, False)
                        LoTab.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshSelectedItemProperties(LoTab.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram.ActiveItem, False)
                End Select
            Next
        Catch ex As Exception
            LogEventFromException(ex, , , )
        End Try
    End Sub
#End Region

    '#######################################
    'execute function
    Public Function Execute(ByRef OoAction As ClsAction) As GeActionResult
        Try
            Dim LeResult As GeActionResult = GeActionResult.kkOk
            '---------------------------------------------
            'ACTION BEFORE ACTION
            '---------------------------------------------
            '---------------------------------------------
            'ACTION
            '---------------------------------------------
            Select Case OoAction.Action
                Case GeAction.kkInitTab
                    ''DOCASNE'' - nastavit disable
                    MoTabPage = OoAction.GetData("TABPAGE")

                    Select Case MoTabPage.TypeOfTab
                        Case GeTypeOfTab.kkNone
                            LogEvent("Nespravny typ tabu!", , )
                        Case GeTypeOfTab.kkMainTab
                            MoOpenedAmodFiles = New ClsMMCollection
                    End Select

                    'initialization of usercontrol for the first usage
                    MoUcnDiagramCanvasAdvanced = OoAction.GetData("UCNDIAGRAMCANVASADVANCED")
                    MeSideOfCanvas = OoAction.GetData("SIDEOFCANVAS")
                    MoTabControl = OoAction.GetData("TABCONTROL")
                    MoMainTabPage = OoAction.GetData("MAINTABPAGE")
                    Dim LoDockManager As DockManager = OoAction.GetData("DOCKMANAGER")
                    Dim LoDockPanels As Collection = OoAction.GetData("DOCKPANELSCOLLECTION")
                    InitDockPanelsSettings(LoDockManager, LoDockPanels)

                    'assigning pointers of usercontrols to ucnDiagramCanvasBase
                    MoUcnPropertiesOfItemUC = OoAction.GetData("ucnPropertiesOfItemUC")
                    MoUcnPropertiesOfTableRowsUC = OoAction.GetData("ucnPropertiesOfTableRowsUC")
                    MoUcnDiagramCanvasAdvanced.nbgPropertiesOfTableRows.GroupClientHeight = 355
                    MoUcnRTFeditorUC = OoAction.GetData("ucnRTFeditorUC")
                    MoUcnRelationsUC = OoAction.GetData("ucnRelations")
                    MoUcnJoinedModulesInfoUC = OoAction.GetData("ucnJoinedModulesInfoUC")
                    MoUcnVersionsChangesUC = OoAction.GetData("ucnVersionsChangesUC")
                    MoItemChangesMemoEdit = OoAction.GetData("meItemChanges")

                    'some assignments after dock panels and other controls are ready
                    Select Case MoTabPage.TypeOfTab
                        Case GeTypeOfTab.kkNone
                            LogEvent("Nespravny typ tabu!", , )
                        Case GeTypeOfTab.kkMainTab
                            xtrRibbonControl.SelectedPage = rpSolution
                        Case GeTypeOfTab.kkClassDiagramTab
                            'reflection of type of link to hand object
                            MoHand.TypeOfLink = KrosLib.Data.eRelationType.OneToMany
                            MoUcnRelationsUC_MMSelectedIndexChanged()
                            xtrRibbonControl.SelectedPage = rpModule
                        Case GeTypeOfTab.kkUseCaseTab
                            'reflection of type of link to hand object
                            MoHand.TypeOfLink = GeTypeOfRelationship.kkUseCaseDiagramAssociation
                            MoUcnRelationsUC_MMSelectedIndexChanged()
                            xtrRibbonControl.SelectedPage = rpUseCaseDiagram
                        Case GeTypeOfTab.kkVersionComparisonTab
                            xtrRibbonControl.SelectedPage = rpModule
                    End Select
                Case GeAction.kkCloseTab
                    Select Case MoTabPage.TypeOfTab
                        Case GeTypeOfTab.kkMainTab
                            OoAction.Action = GeAction.kkaModSolutionCloseFile
                            LeResult = Execute(OoAction)
                            OoAction.Action = GeAction.kkCloseTab
                        Case GeTypeOfTab.kkClassDiagramTab
                            OoAction.Action = GeAction.kkaModCloseVersion
                            LeResult = Execute(OoAction)
                            OoAction.Action = GeAction.kkCloseTab
                        Case GeTypeOfTab.kkUseCaseTab
                            OoAction.Action = GeAction.kkaModCloseUCDofModule
                            LeResult = Execute(OoAction)
                            OoAction.Action = GeAction.kkCloseTab
                        Case GeTypeOfTab.kkVersionComparisonTab
                            OoAction.Action = GeAction.kkaModCloseVersion
                            LeResult = Execute(OoAction)
                            OoAction.Action = GeAction.kkCloseTab
                        Case GeTypeOfTab.kkNone
                            LogEvent("CHYBA!!! - Execute - ACTION - kkCloseTab")
                    End Select

                    If LeResult = GeActionResult.kkOk AndAlso (MoTabPage.TypeOfTab = GeTypeOfTab.kkClassDiagramTab Or MoTabPage.TypeOfTab = GeTypeOfTab.kkUseCaseTab Or MoTabPage.TypeOfTab = GeTypeOfTab.kkVersionComparisonTab) Then
                        Select Case LeResult
                            Case GeActionResult.kkOk
                                'LoTabPage.Dispose()

                                '------------------ END OF LIFE OF TAB ------------------
                                MoTabControl.RemoveTab(MoTabPage)
                                '------------------ END OF LIFE OF TAB ------------------

                            Case GeActionResult.kkCancel
                                'do nothing
                            Case GeActionResult.kkError
                                LogEvent("CHYBA!!! - Execute - ACTION - GeAction.kkCloseTab")
                        End Select
                    End If
                Case GeAction.kkaModTryToOpenVersions
                    'if tab with this version is opened, focus it. Or create new tab
                    Dim LsAmodFilePath As String = OoAction.GetData("PATHTOFILE")
                    Dim LoVersions As Collection = OoAction.GetData("VERSIONS")
                    ''removes "PATHTOFILE" coz from this moment Im going to use LoDSaModFile.Path property
                    'OoAction.RemoveData("PATHTOFILE")

                    For Each LiVID As Integer In LoVersions
                        OoAction.SetData(LiVID, "VERSION")
                        'is file already opened?
                        Dim LoDSaModFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodFilePath, True)
                        If LoDSaModFile IsNot Nothing Then
                            OoAction.SetData(LoDSaModFile, "DSAMODFILE") ' set LoDSaModFile for future use
                            'is version opened?
                            If LiVID = -1 Then LiVID = LoDSaModFile.Dat.GetLastVersion
                            If LoDSaModFile.OpenedEditableVersions.IsItemInCollection(CStr(LiVID)) Then
                                Dim LoTab As ClsUcnTabPage = MoTabControl.GetTabClassDiagram(LoDSaModFile.Path, LiVID)
                                OoAction.SetData(LoTab, "TABPAGE")
                                LeResult = MoTabControl.FocusTab(LoTab)
                            Else
                                'open version
                                LeResult = MoTabControl.Execute(OoAction)
                            End If
                        Else
                            'open aMod file
                            OoAction.Action = GeAction.kkaModOpenFile
                            LeResult = Execute(OoAction)
                            OoAction.Action = GeAction.kkaModTryToOpenVersions
                            'and now open version
                            If LeResult = GeActionResult.kkOk Then
                                LeResult = MoTabControl.Execute(OoAction)
                            End If
                        End If
                    Next
                Case GeAction.kkaModTryToCompareVersions
                    Dim LiLeftVersion As Integer = OoAction.GetData("LEFTVERSION")
                    Dim LiRightVersion As Integer = OoAction.GetData("RIGHTVERSION")
                    Dim LsAmodFilePath As String = OoAction.GetData("PATHTOFILE")
                    Dim LoDSaModFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodFilePath, True)
                    Dim LoLeftDsAModOneVersion As AMod2.DsAModOneVersion = LoDSaModFile.Dat.GetVersionDataset(LiLeftVersion)
                    Dim LoRightDsAModOneVersion As AMod2.DsAModOneVersion = LoDSaModFile.Dat.GetVersionDataset(LiRightVersion)

                    Dim LoDSversionCompare As ClsDSversionCompare = New ClsDSversionCompare
                    LoDSversionCompare.Compare(LoLeftDsAModOneVersion, LoRightDsAModOneVersion)

                    If LoDSversionCompare.DsChanges IsNot Nothing Then
                        Dim LoTab As ClsUcnTabPage = Nothing

                        'if tab with this versions is opened, focus it. Or create new tab
                        'is file already opened?
                        If LoDSaModFile IsNot Nothing Then
                            OoAction.SetData(LoDSaModFile, "DSAMODFILE") ' set LoDSaModFile for future use
                            'are versions opened?
                            LoTab = MoTabControl.GetTabComparedVersions(LoDSaModFile.Path, LiLeftVersion, LiRightVersion)
                            If LoTab IsNot Nothing Then
                                LeResult = MoTabControl.FocusTab(LoTab)
                            Else
                                'save left and right versions if needed. Then I will open those versions in readonly mode
                                Dim LbSaveLeftVersion As Boolean = False
                                Dim LbSaveRightVersion As Boolean = False

                                Dim LoDsAModOneVersion As ClsDsAModOneVersion = LoDSaModFile.OpenedEditableVersions.GetItem(CStr(LiLeftVersion), True)
                                If LoDsAModOneVersion IsNot Nothing AndAlso LoDsAModOneVersion.WasModified Then
                                    LbSaveLeftVersion = True
                                End If

                                LoDsAModOneVersion = LoDSaModFile.OpenedEditableVersions.GetItem(CStr(LiRightVersion), True)
                                If LoDsAModOneVersion IsNot Nothing AndAlso LoDsAModOneVersion.WasModified Then
                                    LbSaveRightVersion = True
                                End If

                                If LbSaveLeftVersion AndAlso LbSaveRightVersion Then
                                    If MessageBox.Show("Pred touto operaciou je potrebne ulozit neulozene zmeny vo verziach " & LiLeftVersion & " a " & LiRightVersion & ". Chcete ulozit zmeny a pokracovat v operacii?", "Ulozenie zmien vo verziach", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                                        Dim LoLeftTabClassDiagram As ClsUcnTabPage = MoTabControl.GetTabClassDiagram(LoDSaModFile.Path, LiLeftVersion)
                                        OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                        LeResult = LoLeftTabClassDiagram.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                        OoAction.Action = GeAction.kkaModTryToCompareVersions

                                        If LeResult = GeActionResult.kkOk Then
                                            Dim LoRightTabClassDiagram As ClsUcnTabPage = MoTabControl.GetTabClassDiagram(LoDSaModFile.Path, LiRightVersion)
                                            OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                            LeResult = LoRightTabClassDiagram.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                            OoAction.Action = GeAction.kkaModTryToCompareVersions
                                        End If
                                    Else
                                        LeResult = GeActionResult.kkCancel
                                    End If
                                ElseIf LbSaveLeftVersion Then
                                    If MessageBox.Show("Pred touto operaciou je potrebne ulozit neulozene zmeny vo verzii " & LiLeftVersion & ". Chcete ulozit zmeny a pokracovat v operacii?", "Ulozenie zmien vo verziach", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                                        Dim LoLeftTabClassDiagram As ClsUcnTabPage = MoTabControl.GetTabClassDiagram(LoDSaModFile.Path, LiLeftVersion)
                                        OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                        LeResult = LoLeftTabClassDiagram.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                        OoAction.Action = GeAction.kkaModTryToCompareVersions
                                    Else
                                        LeResult = GeActionResult.kkCancel
                                    End If
                                ElseIf LbSaveRightVersion Then
                                    If MessageBox.Show("Pred touto operaciou je potrebne ulozit neulozene zmeny vo verzii " & LiRightVersion & ". Chcete ulozit zmeny a pokracovat v operacii?", "Ulozenie zmien vo verziach", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                                        Dim LoRightTabClassDiagram As ClsUcnTabPage = MoTabControl.GetTabClassDiagram(LoDSaModFile.Path, LiRightVersion)
                                        OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                        LeResult = LoRightTabClassDiagram.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                        OoAction.Action = GeAction.kkaModTryToCompareVersions
                                    Else
                                        LeResult = GeActionResult.kkCancel
                                    End If
                                End If

                                If LeResult = GeActionResult.kkOk Then
                                    'open versions for compare - dont check if version is opened!
                                    LeResult = MoTabControl.Execute(OoAction)
                                    LoTab = OoAction.GetData("TABPAGE")
                                End If
                                End If
                        Else
                                'open aMod file
                                OoAction.Action = GeAction.kkaModOpenFile
                                LeResult = Execute(OoAction)
                                OoAction.Action = GeAction.kkaModTryToOpenVersions
                            'and now open version - dont check if version is opened!
                                If LeResult = GeActionResult.kkOk Then
                                    LeResult = MoTabControl.Execute(OoAction)
                                    LoTab = OoAction.GetData("TABPAGE")
                                End If
                        End If

                        If LeResult = GeActionResult.kkOk Then
                            OoAction.Action = GeAction.kkaModColorComparedVersion
                            OoAction.SetData(LoDSversionCompare, "DSVERSIONCOMPARE")
                            LoTab.LeftCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                            LoTab.RightCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                            OoAction.Action = GeAction.kkaModTryToCompareVersions
                        End If
                    End If
                Case GeAction.kkaModColorComparedVersion
                    MoDSversionCompare = OoAction.GetData("DSVERSIONCOMPARE")
                    MoUcnVersionsChangesUC.Init(Nothing)
                    LeResult = MoDSversionCompare.ColorDiagram(MeSideOfCanvas, fcDiagram)

                Case GeAction.kkaModTryToOpenUCDofModule
                        'if tab with this UCD is opened, focus it. Or create new tab
                        Dim LsAmodFilePath As String = OoAction.GetData("PATHTOFILE")

                        'is file already opened?
                        Dim LoDSaModFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodFilePath, True)
                        If LoDSaModFile IsNot Nothing Then
                            OoAction.SetData(LoDSaModFile, "DSAMODFILE") ' set LoDSaModFile for future use
                            'is UCD opened?
                            Dim LoTab As ClsUcnTabPage = MoTabControl.GetTabUCD(LoDSaModFile.Path)
                            If LoTab IsNot Nothing Then
                                LeResult = MoTabControl.FocusTab(LoTab)
                            Else
                                'open UCD
                                LeResult = MoTabControl.Execute(OoAction)
                            End If
                        Else
                            'open aMod file
                            OoAction.Action = GeAction.kkaModOpenUCDofModule
                            LeResult = Execute(OoAction)
                            OoAction.Action = GeAction.kkaModTryToOpenUCDofModule
                            'and now open version
                            If LeResult = GeActionResult.kkOk Then
                                LeResult = MoTabControl.Execute(OoAction)
                            End If
                        End If

                        Debug.Print("LALA")
                Case GeAction.kkaModOpenUCDofModule
                        'opening UCD in tab
                        MoDSaModFile = OoAction.GetData("DSAMODFILE")

                        If MoDSaModFile.OpenUseCaseDiagram = GeActionResult.kkOk Then
                            'load diagram to FC - with try block, coz in new aMod file or after import theres not proper format of FlowChart data
                            Try
                                Me.fcDiagram.LoadFromString(MoDSaModFile.GetUseCaseDiagramData)
                            Catch ex As Exception
                            Finally
                                SetFileWasModified(False)
                            End Try
                        End If
                Case GeAction.kkaModOpenFile
                        'opening version of aMod in tab
                        Dim LsAmodFilePath As String = OoAction.GetData("PATHTOFILE")

                        Dim LoDSaModFile As ClsDSaModFile = Nothing
                        LeResult = QuickOpenAmodFile(LsAmodFilePath, LoDSaModFile)
                        If LeResult = GeActionResult.kkOk Then
                            OoAction.SetData(LoDSaModFile, "DSAMODFILE") ' set LoDSaModFile for future use
                        End If
                        If LeResult = GeActionResult.kkOk Then MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.AddItem(LoDSaModFile, LoDSaModFile.Path)
                Case GeAction.kkaModOpenVersion
                        'opening version of aMod in tab
                        MoDSaModFile = OoAction.GetData("DSAMODFILE")
                        Dim LiVID As Integer = OoAction.GetData("VERSION")
                        MoLeftCanvasBase = OoAction.GetData("LEFTCANVASBASE", Nothing)
                        MoRightCanvasBase = OoAction.GetData("RIGHTCANVASBASE", Nothing)
                        Dim LbOpenedForReading As Boolean = OoAction.GetData("OPENEDVERSIONFORREADING", False)

                        If LiVID = -1 Then LiVID = MoDSaModFile.Dat.GetLastVersion

                        MoAmodVersion = MoDSaModFile.OpenVersion(LiVID, LbOpenedForReading)
                        If MoAmodVersion IsNot Nothing Then
                            'load diagram to FC - with try block, coz in new aMod file or after import theres not proper format of FlowChart data
                            Try
                                Me.fcDiagram.LoadFromString(AmodVersion.GetClassDiagramData)
                                SetFileWasModified(False)
                            Catch ex As Exception
                                'bulid diagram
                                OoAction.Action = GeAction.kkBuildDiagram
                                LeResult = Execute(OoAction)
                                OoAction.Action = GeAction.kkaModOpenVersion

                                OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                Execute(OoAction)
                                OoAction.Action = GeAction.kkaModOpenVersion
                            End Try
                        Else
                            LeResult = GeActionResult.kkError
                        End If
                Case GeAction.kkaModSaveVersionAndFile
                        Select Case MoDSaModFile.StateOfFile
                            Case GeFileState.kkNewFile
                                LogEvent("Nova verzia aMod suboru zatial nepodporovana!", , )
                                LeResult = GeActionResult.kkError
                            Case GeFileState.kkOpened
                                'do nothing
                                LeResult = GeActionResult.kkOk
                            Case Else
                                LogEvent("Nova verzia aMod suboru zatial nepodporovana!", , )
                                LeResult = GeActionResult.kkError
                        End Select

                        If LeResult = GeActionResult.kkOk Then
                            'save diagram data
                            LeResult = AmodVersion.UpdateClassDiagramData(Me.fcDiagram.SaveToString(SaveToStringFormat.Xml, True))
                            If LeResult = GeActionResult.kkOk Then
                                'save version
                                LeResult = MoDSaModFile.SaveVersion(AmodVersion.GetVersionVID)
                                'save aMod file
                                If LeResult = GeActionResult.kkOk Then
                                    OoAction.Action = GeAction.kkaModSaveFile
                                    LeResult = Execute(OoAction)
                                    OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                End If
                            End If
                        End If
                Case GeAction.kkaModSaveFile
                        Select Case MoDSaModFile.StateOfFile
                            Case GeFileState.kkNewFile
                                LogEvent("Nova verzia aMod suboru zatial nepodporovana!", , )
                                LeResult = GeActionResult.kkError
                            Case GeFileState.kkOpened
                                'do nothing
                                LeResult = GeActionResult.kkOk
                            Case Else
                                LogEvent("Nova verzia aMod suboru zatial nepodporovana!", , )
                                LeResult = GeActionResult.kkError
                        End Select

                        If LeResult = GeActionResult.kkOk Then
                            LeResult = MoDSaModFile.SaveFile()
                        End If
                Case GeAction.kkaModSolutionSaveFile
                        Select Case MoDSaModSolutionFile.StateOfFile
                            Case GeFileState.kkNewFile
                                LogEvent("Novy suboru aMod projektu zatial nepodporovany!", , )
                                LeResult = GeActionResult.kkError
                            Case GeFileState.kkOpened
                                'do nothing
                                LeResult = GeActionResult.kkOk
                            Case Else
                                LogEvent("Nova verzia aMod suboru zatial nepodporovana!", , )
                                LeResult = GeActionResult.kkError
                        End Select

                        If LeResult = GeActionResult.kkOk Then
                            LeResult = MoDSaModSolutionFile.UpdateDiagramData(Me.fcDiagram.SaveToString(SaveToStringFormat.Xml, True))
                            If LeResult = GeActionResult.kkOk Then
                                LeResult = MoDSaModSolutionFile.SaveFile(False)
                            End If
                        End If
                Case GeAction.kkaModSaveUCDofModuleAndFile
                        If LeResult = GeActionResult.kkOk Then
                            'save use case diagram data
                            LeResult = MoDSaModFile.UpdateUseCaseDiagramData(Me.fcDiagram.SaveToString(SaveToStringFormat.Xml, True))
                            If LeResult = GeActionResult.kkOk Then
                                'save aMod file
                                If LeResult = GeActionResult.kkOk Then
                                    OoAction.Action = GeAction.kkaModSaveFile
                                    LeResult = Execute(OoAction)
                                    OoAction.Action = GeAction.kkaModSaveUCDofModuleAndFile
                                    SetFileWasModified(False)
                                End If
                            End If
                            If LeResult = GeActionResult.kkOk Then
                                barBtnSaveUCDofModule.Enabled = False
                            Else
                                barBtnSaveUCDofModule.Enabled = True
                            End If
                        End If
                Case GeAction.kkSaveAll
                        OoAction.Action = GeAction.kkaModSolutionSaveFile
                        LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                        OoAction.Action = GeAction.kkSaveAll

                        OoAction.Action = GeAction.kkaModSaveAllAmodFilesAndTheirVersions
                        LeResult = Execute(OoAction)
                        OoAction.Action = GeAction.kkSaveAll
                Case GeAction.kkaModCloseVersion
                        Select Case AmodVersion.StateOfDS
                            Case GeDataSetState.kkNotInit
                                LogEvent("Pokus o zavretie neotvorenej verzie!", , )
                                LeResult = GeActionResult.kkError
                            Case GeDataSetState.kkOpened
                                If AmodVersion.WasModified Then
                                    Select Case MessageBox.Show("Ulozit vykonane zmeny v module """ & MoDSaModFile.GetLastVersionHumanModuleName & """ (verzia " & AmodVersion.GetVersionVID & ")?", "Ulozenie zmien", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
                                        Case DialogResult.Yes
                                            OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                            LeResult = Execute(OoAction)
                                            OoAction.Action = GeAction.kkaModCloseVersion
                                        Case DialogResult.No
                                            LeResult = GeActionResult.kkOk
                                        Case DialogResult.Cancel
                                            LeResult = GeActionResult.kkCancel
                                    End Select
                                End If
                            Case Else
                                Debug.Print("CHYBA!!! - Execute - ACTION - kkaModCloseVersion")
                                LeResult = GeActionResult.kkError
                        End Select

                        If LeResult = GeActionResult.kkOk Then
                            LeResult = MoDSaModFile.CloseVersion(AmodVersion)

                            If LeResult = GeActionResult.kkOk Then
                                'clear diagram - all groups, links and nodes in the diagram
                                ClearAllComponents()

                                '------------------ END OF LIFE OF aMod VERSION ------------------
                                MoAmodVersion = Nothing
                                '------------------ END OF LIFE OF aMod VERSION ------------------

                                'try to close file
                                OoAction.Action = GeAction.kkaModCloseFile
                                LeResult = Execute(OoAction)
                                OoAction.Action = GeAction.kkaModCloseVersion
                            End If
                        End If
                Case GeAction.kkaModCloseFile
                        If LeResult = GeActionResult.kkOk Then
                            If MoDSaModFile.OpenedEditableVersions.IsEmpty AndAlso MoDSaModFile.OpenedReadOnlyVersions.IsEmpty AndAlso Not MoDSaModFile.OpenedUseCaseDiagram Then
                                Dim LsAmodFilePath As String = AmodFilePath 'backup of Amod file path coz after MoDSaModFile.CloseFile theres no proper value for MoDSaModFile.Path, theres empty string
                                LeResult = MoDSaModFile.CloseFile
                                If LeResult = GeActionResult.kkOk Then
                                    LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.RemoveItem(LsAmodFilePath)
                                    If LeResult = GeActionResult.kkOk Then
                                        '------------------ END OF LIFE OF aMod FILE------------------
                                        MoDSaModFile = Nothing
                                        '------------------ END OF LIFE OF aMod FILE------------------
                                    End If
                                Else
                                    LogEvent("Chyba pri zatvarani suboru!", , )
                                End If
                            End If
                        End If
                Case GeAction.kkaModCloseUCDofModule
                        If barBtnSaveUCDofModule.Enabled Then
                            Select Case MessageBox.Show("Ulozit vykonane zmeny v use case diagrame modulu """ & MoDSaModFile.GetLastVersionHumanModuleName & """?", "Ulozenie zmien use case diagramu", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
                                Case DialogResult.Yes
                                    LeResult = MoDSaModFile.UpdateUseCaseDiagramData(Me.fcDiagram.SaveToString(SaveToStringFormat.Xml, True))
                                    OoAction.Action = GeAction.kkaModSaveFile
                                    LeResult = Execute(OoAction)
                                    OoAction.Action = GeAction.kkaModCloseUCDofModule
                                Case DialogResult.No
                                    LeResult = GeActionResult.kkOk
                                Case DialogResult.Cancel
                                    LeResult = GeActionResult.kkCancel
                            End Select
                        End If

                        If LeResult = GeActionResult.kkOk Then LeResult = MoDSaModFile.CloseUseCaseDiagram

                        'try to close file
                        OoAction.Action = GeAction.kkaModCloseFile
                        LeResult = Execute(OoAction)
                        OoAction.Action = GeAction.kkaModCloseVersion
                Case GeAction.kkaModSolutionNewSolution
                        'close file if needed
                        If MoDSaModSolutionFile IsNot Nothing Then
                            Select Case MoDSaModSolutionFile.StateOfFile
                                Case GeFileState.kkNewFile, GeFileState.kkOpened
                                    'close file
                                    ''DOCASNE'' - zavretie vsetkych aModov + solution
                                    OoAction.SetData(False, "ASKFORCLOSINGPROJECT")
                                    OoAction.Action = GeAction.kkaModSolutionCloseFile
                                    LeResult = Execute(OoAction)
                                    OoAction.Action = GeAction.kkaModSolutionNewSolution
                                Case GeFileState.kkNotInit, GeFileState.kkReadyForOpen
                                    'nothing to close
                                Case Else
                                    Debug.Print("CHYBA!!! - Execute - ACTION - kkNewFile")
                                    LeResult = GeActionResult.kkError
                            End Select
                        End If

                        If LeResult = GeActionResult.kkOk Then
                            Dim LoDfrmNewAmodSolution As ClsDfrmNewAmodSolution = New ClsDfrmNewAmodSolution
                            LeResult = LoDfrmNewAmodSolution.Execute(OoAction)

                            If LeResult = GeActionResult.kkOk Then
                                MoDSaModSolutionFile = New ClsDSaModSolutionFile()

                                OoAction.Action = GeAction.kkaModSolutionCreateVirginFile
                                LeResult = Execute(OoAction)
                                OoAction.Action = GeAction.kkaModSolutionNewSolution

                                If LeResult = GeActionResult.kkOk Then
                                    'clear diagram - all groups, links and nodes in the diagram
                                    ClearAllComponents()
                                    'fills MoUcnComboboxJoinedModule in main tab with all modules from aMod solution
                                    MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.FillComboboxJoinedModule()
                                Else
                                    MoDSaModSolutionFile = Nothing
                                    LeResult = GeActionResult.kkError
                                End If
                            End If
                        End If
                Case GeAction.kkaModSolutionCreateVirginFile
                        LeResult = MoDSaModSolutionFile.CreateVirginFile(OoAction.GetData("SOLUTIONNAME"), OoAction.GetData("SOLUTIONPATH"), OoAction.GetData("MODULESDIRECTORYNAME"))
                Case GeAction.kkaModCreateVirginFile
                        Dim LsModuleName As String = OoAction.GetData("MODULENAME")
                        Dim LsHumanModuleName As String = OoAction.GetData("HUMANMODULENAME")
                        Dim LoDSaModFile As ClsDSaModFile = New ClsDSaModFile(LsModuleName, LsHumanModuleName)

                        LeResult = LoDSaModFile.CreateVirginFile(OoAction.GetData("AMODPATH"))
                Case GeAction.kkaModSolutionOpenFile
                        'close file if needed
                        If MoDSaModSolutionFile IsNot Nothing Then
                            Select Case MoDSaModSolutionFile.StateOfFile
                                Case GeFileState.kkNewFile, GeFileState.kkOpened
                                    'close file
                                    ''DOCASNE'' - zavretie vsetkych aModov + solution
                                OoAction.Action = GeAction.kkaModSolutionCloseFile
                                OoAction.SetData(False, "ASKFORCLOSINGPROJECT")
                                    LeResult = Execute(OoAction)
                                    OoAction.Action = GeAction.kkaModSolutionOpenFile
                                Case GeFileState.kkNotInit, GeFileState.kkReadyForOpen
                                    'nothing to close
                                Case Else
                                    Debug.Print("CHYBA!!! - Execute - ACTION - kkNewFile")
                                    LeResult = GeActionResult.kkError
                            End Select
                        End If

                        If LeResult = GeActionResult.kkOk Then
                            Dim LsaModSolutionFilePath As String = OoAction.GetData("AMODSOLUTIONFILEPATH")

                            MoDSaModSolutionFile = New ClsDSaModSolutionFile
                            LeResult = MoDSaModSolutionFile.Init(LsaModSolutionFilePath)
                            If LeResult = GeActionResult.kkOk Then
                                'file was opened successfully
                                LeResult = MoDSaModSolutionFile.OpenFile
                                If LeResult = GeActionResult.kkOk Then
                                    'load diagram to FC - with try block, coz in new aMod file is saved not proper format of FlowChart data
                                    Try
                                        Me.fcDiagram.LoadFromString(MoDSaModSolutionFile.GetClassDiagramData)
                                        'fills MoUcnComboboxJoinedModule in main tab with all modules from aMod solution
                                        MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.FillComboboxJoinedModule()

                                        SetFileWasModified(False)
                                    Catch ex As Exception
                                        LeResult = GeActionResult.kkOk
                                    End Try
                                Else
                                    LeResult = GeActionResult.kkError
                                End If
                            Else
                                MoDSaModSolutionFile = Nothing
                                LeResult = GeActionResult.kkError
                            End If
                        End If
                Case GeAction.kkaModSolutionCloseFile
                        'MoDSaModSolutionFile can be nothing when no aMod solution is opened
                        If MoDSaModSolutionFile IsNot Nothing Then
                            'aMod solution is opened
                            Select Case MoDSaModSolutionFile.StateOfFile
                                Case GeFileState.kkNewFile, GeFileState.kkOpened
                                    Dim LbClose As Boolean = True
                                    If Not MoOpenedAmodFiles.IsEmpty Then
                                        Dim LbAskForClosing As Boolean = True
                                        LbAskForClosing = OoAction.GetData("ASKFORCLOSINGPROJECT")

                                        If LbAskForClosing Then
                                            Select Case MessageBox.Show("Pre zatvorenie projektu je potrebne zavriet vsetky otvorene moduly tohto projektu. Chcete ich zavriet a pokracovat v zatvarani projektu? ", "Zatvorenie modulov projektu", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                                                Case DialogResult.Yes
                                                    LbClose = True
                                                Case DialogResult.No
                                                    LbClose = False
                                                    LeResult = GeActionResult.kkCancel
                                            End Select
                                        Else
                                            LbClose = True
                                        End If
                                    End If

                                    If LbClose = True Then
                                        OoAction.Action = GeAction.kkaModCloseAllAmodFilesAndTheirVersions
                                        LeResult = Execute(OoAction)
                                        OoAction.Action = GeAction.kkaModSolutionCloseFile

                                        'if all tabs are closed -> close aMod solution file
                                        If LeResult = GeActionResult.kkOk And MoOpenedAmodFiles.IsEmpty Then
                                            If MoDSaModSolutionFile.FileWasModified Then
                                                Select Case MessageBox.Show("Ulozit vykonane zmeny v aMod projekte?", "Ulozenie zmien", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
                                                    Case DialogResult.Yes
                                                        OoAction.Action = GeAction.kkaModSolutionSaveFile
                                                        LeResult = Execute(OoAction)
                                                        OoAction.Action = GeAction.kkaModSolutionCloseFile
                                                    Case DialogResult.No
                                                        LeResult = GeActionResult.kkOk
                                                    Case DialogResult.Cancel
                                                        LeResult = GeActionResult.kkCancel
                                                End Select
                                            End If

                                            If LeResult = GeActionResult.kkOk Then
                                                LeResult = MoDSaModSolutionFile.CloseFile

                                                If LeResult = GeActionResult.kkOk Then
                                                    'clear diagram - all groups, links and nodes in the diagram
                                                    ClearAllComponents()
                                                    MoOpenedAmodFiles = Nothing
                                                    MoOpenedAmodFiles = New ClsMMCollection
                                                    '------------------ END OF LIFE OF aMod Solution FILE ------------------
                                                    MoDSaModSolutionFile = Nothing
                                                    '------------------ END OF LIFE OF aMod Solution FILE ------------------
                                                Else
                                                    LogEvent("Chyba pri zatvarani zalozky s projektom!")
                                                End If
                                            End If
                                        End If
                                    End If
                                Case GeFileState.kkNotInit, GeFileState.kkReadyForOpen
                                    LeResult = GeActionResult.kkOk
                                Case Else
                                    Debug.Print("CHYBA!!! - Execute - ACTION - kkaModSolutionCloseFile")
                                    LeResult = GeActionResult.kkError
                            End Select
                        Else
                            'no aMod solution is opened
                            LeResult = GeActionResult.kkOk
                        End If
                Case GeAction.kkaModCloseAllAmodFilesAndTheirVersions
                        OoAction.Action = GeAction.kkaModCloseAllVersionsOfAmodFile
                        For Each LoDSaModFile As ClsDSaModFile In MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetCollection
                            If LeResult <> GeActionResult.kkCancel Then
                                OoAction.SetData(LoDSaModFile, "AMODFILE")
                                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                            End If
                        Next

                        OoAction.Action = GeAction.kkaModCloseAllAmodFilesAndTheirVersions
                        ''LeResult = GeActionResult.kkOk
                Case GeAction.kkaModCloseAllVersionsOfAmodFile
                        Dim LoDSaModFile As ClsDSaModFile = OoAction.GetData("AMODFILE")
                        Dim LsAmodPath As String = LoDSaModFile.Path
                        OoAction.Action = GeAction.kkCloseTab

                        'close all editable versions
                        For Each LoDDsAModOneVersion As ClsDsAModOneVersion In LoDSaModFile.OpenedEditableVersions.GetCollection
                            If LeResult <> GeActionResult.kkCancel Then
                                LeResult = MoTabControl.GetTabClassDiagram(LsAmodPath, LoDDsAModOneVersion.GetVersionVID).Execute(OoAction)
                            End If
                        Next
                        'close use case diagram
                        If LeResult = GeActionResult.kkOk Then
                            Dim LoUseCaseTab As ClsUcnTabPage = MoTabControl.GetTabUCD(LsAmodPath)
                            If LoUseCaseTab IsNot Nothing Then
                                LeResult = LoUseCaseTab.Execute(OoAction)
                            End If
                        End If
                        'close compare versions tabs
                        If LeResult = GeActionResult.kkOk Then
                            For Each LoComparedVersionsTab As ClsUcnTabPage In MoTabControl.GetAllTabsComparedVersionsByAmodPath(LsAmodPath)
                                If LeResult <> GeActionResult.kkCancel Then
                                    LeResult = LoComparedVersionsTab.Execute(OoAction)
                                End If
                            Next
                        End If

                        OoAction.Action = GeAction.kkaModCloseAllVersionsOfAmodFile
                        'LeResult = GeActionResult.kkOk

                        ' ''OoAction.Action = GeAction.kkCloseTab
                        ' ''While LoDSaModFile.OpenedVersions.Count > LiI + LiNumberOfErrors
                        ' ''    LoDDsAModOneVersion = LoDSaModFile.OpenedVersions.GetCollection.Item(LiI + 1)
                        ' ''    LiVersion = LoDDsAModOneVersion.GetVersionVID
                        ' ''    LsAmodPath = LoDSaModFile.Path
                        ' ''    If MoTabControl.GetTab(LsAmodPath, LiVersion).Execute(OoAction) = GeActionResult.kkError Then LiNumberOfErrors = LiNumberOfErrors + 1
                        ' ''End While
                Case GeAction.kkaModSaveAllAmodFilesAndTheirVersions
                        OoAction.Action = GeAction.kkaModSaveAllVersionsOfAmodFile
                        For Each LoDSaModFile As ClsDSaModFile In MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetCollection
                            If LeResult <> GeActionResult.kkCancel Then
                                OoAction.SetData(LoDSaModFile, "AMODFILE")
                                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                            End If
                        Next

                        OoAction.Action = GeAction.kkaModSaveAllAmodFilesAndTheirVersions
                Case GeAction.kkaModSaveAllVersionsOfAmodFile
                        Dim LoDSaModFile As ClsDSaModFile = OoAction.GetData("AMODFILE")
                        Dim LsAmodPath As String = LoDSaModFile.Path
                        OoAction.Action = GeAction.kkaModSaveVersionAndFile

                        'save all editable versions
                        For Each LoDDsAModOneVersion As ClsDsAModOneVersion In LoDSaModFile.OpenedEditableVersions.GetCollection
                            If LeResult <> GeActionResult.kkCancel AndAlso LoDDsAModOneVersion.WasModified = True Then
                                LeResult = MoTabControl.GetTabClassDiagram(LsAmodPath, LoDDsAModOneVersion.GetVersionVID).ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                            End If
                        Next
                        'save use case diagram
                        If LeResult = GeActionResult.kkOk Then
                            Dim LoUseCaseTab As ClsUcnTabPage = MoTabControl.GetTabUCD(LsAmodPath)
                            If LoUseCaseTab IsNot Nothing Then
                                OoAction.Action = GeAction.kkaModSaveUCDofModuleAndFile
                                LeResult = LoUseCaseTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                            End If
                        End If

                        OoAction.Action = GeAction.kkaModSaveAllVersionsOfAmodFile
                Case GeAction.kkaModOpenPathTarget
                        OoAction.SetData(MoDSaModFile.Path, "PATH")
                        OoAction.Action = GeAction.kkOpenPathInExplorer
                        LeResult = Execute(OoAction)
                        OoAction.Action = GeAction.kkaModOpenPathTarget
                Case GeAction.kkaModSolutionOpenPathTarget
                        OoAction.SetData(MoDSaModSolutionFile.Path, "PATH")
                        OoAction.Action = GeAction.kkOpenPathInExplorer
                        LeResult = Execute(OoAction)
                        OoAction.Action = GeAction.kkaModSolutionOpenPathTarget
                Case GeAction.kkOpenPathInExplorer
                        Dim LsPath As String = OoAction.GetData("PATH")
                        Try
                            '''''open directory
                            ''''Process.Start("explorer.exe", LsPath)
                            'open directory and focus file
                            Call Shell("explorer /select," & LsPath, AppWinStyle.NormalFocus)
                            LeResult = GeActionResult.kkOk
                        Catch ex As Exception
                            LogEvent("Chyba pri otvarani adresara so suborom: " & LsPath)
                            LeResult = GeActionResult.kkError
                        End Try
                Case GeAction.kkaModVersionsManagement
                        Dim LoDfrmVersionsManagement As ClsDfrmVersionsManagement = New ClsDfrmVersionsManagement
                        OoAction.SetData(MoDSaModFile, "DSAMODFILE")
                        OoAction.SetData(Me, "SENDER")
                        LeResult = LoDfrmVersionsManagement.Execute(OoAction)
                Case GeAction.kkamodPromoteVersion
                        Dim LsAmodPath As String = OoAction.GetData("AMODPATHFORPROMOTING")
                        Dim LiVersion As Integer = OoAction.GetData("VERSIONFORPROMOTING")
                        Dim LoDSaModFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodPath)

                        If MessageBox.Show("Naozaj chcete vytvorit novu verziu " & LoDSaModFile.Dat.GetLastVersion + 1 & " povysenim verzie " & LiVersion & "?", "Povysenie verzie", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                            Dim LbSaveVersion As Boolean = GetAllUnsavedVersionsOfAmodFile(LsAmodPath).Contains(LiVersion)
                            If LbSaveVersion Then
                                Dim LoTab As ClsUcnTabPage = MoTabControl.GetTabClassDiagram(LsAmodPath, LiVersion)
                                If MessageBox.Show("Pred touto operaciou je potrebne ulozit neulozene zmeny vo verzii " & LiVersion & ". Chcete ulozit zmeny a pokracovat v operacii?", "Ulozenie zmien vo verzii", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                                    OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                    LeResult = LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                    OoAction.Action = GeAction.kkamodPromoteVersion
                                Else
                                    LeResult = GeActionResult.kkCancel
                                End If
                            End If

                            If LeResult = GeActionResult.kkOk Then
                                LoDSaModFile.InsertDuplicateVersion(LiVersion)

                                'refresh joined modules in modul
                                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshJoinedModulesInModule(LoDSaModFile)

                                'saving aMod file
                                OoAction.Action = GeAction.kkaModSaveFile
                                LeResult = Execute(OoAction)
                                OoAction.Action = GeAction.kkamodPromoteVersion
                                'refreshes joined modules links within main tab diagram
                                If LeResult = GeActionResult.kkOk Then
                                    LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshJoinedModulesLinksOfChildModule(LoDSaModFile.GetLastVersionModuleName)

                                    If LeResult = GeActionResult.kkOk Then
                                        'If MessageBox.Show("Povysenim bola uspesne vytvorena najnovsia verzia (" & LoDSaModFile.Dat.GetLastVersion & "). Zelate si ju otvorit na novej zalozke?", "Uspesne povysena verzia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                                        'open new version
                                        Dim LoVersionToOpen As Collection = New Collection
                                        LoVersionToOpen.Add(LoDSaModFile.Dat.GetLastVersion)

                                        OoAction.SetData(LoVersionToOpen, "VERSIONS")
                                        OoAction.SetData("TEMP NAME", "MODULENAME")
                                        OoAction.SetData(LoDSaModFile.Path, "PATHTOFILE")
                                        OoAction.Action = GeAction.kkaModTryToOpenVersions
                                        LeResult = Execute(OoAction)
                                        OoAction.Action = GeAction.kkamodPromoteVersion
                                        'End If
                                    End If
                                End If

                                'refresh captions and tips of tabs with opened versions from aMod file
                                RefreshCaptionAndTipOfTabsOfAmodFile(LoDSaModFile.Path)
                            End If
                        Else
                            LeResult = GeActionResult.kkCancel
                        End If
                Case GeAction.kkaModDeleteVersions
                        Dim LoVersionsForDelete As Collection = OoAction.GetData("VERSIONSFORDELETE")
                        For Each LiVersion As Integer In LoVersionsForDelete
                            LeResult = MoDSaModFile.DeleteVersion(LiVersion)
                            'theres also saving of aMod file coz VersionModuleName was changed in aMod file DS and not in DsAModOneVersion DS, so theres no "diskette icon" evidence of this change                      
                        Next
                        'refresh joined modules in modul
                        LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshJoinedModulesInModule(MoDSaModFile)
                        'refreshes joined modules links within main tab diagram
                        LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshJoinedModulesLinksOfChildModule(MoDSaModFile.GetLastVersionModuleName)
                        'refresh captions and tips of tabs with opened versions from aMod file
                        RefreshCaptionAndTipOfTabsOfAmodFile(MoDSaModFile.Path)
                Case GeAction.kkaModExportAmodSolutionToProject
                        Dim LbSaveVersions As Boolean = GetAllAmodFilesWithUnsavedVersions.Count > 0
                        Dim LbSaveSolution As Boolean = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.FileWasModified
                        Dim LsQuestionMessage As String = ""
                        Dim LsQuestionCaption As String = ""

                        If LbSaveVersions And LbSaveSolution Then
                            LsQuestionMessage = "Pred touto operaciou je potrebne ulozit vykonane zmeny v projekte a vo vsetkych moduloch. Chcete ulozit zmeny a pokracovat v operacii?"
                            LsQuestionCaption = "Ulozenie zmien v projekte a v moduloch"
                        Else
                            If LbSaveVersions Then
                                LsQuestionMessage = "Pred touto operaciou je potrebne ulozit vykonane zmeny vo vsetkych moduloch. Chcete ulozit zmeny a pokracovat v operacii?"
                                LsQuestionCaption = "Ulozenie zmien v moduloch"
                            ElseIf LbSaveSolution Then
                                LsQuestionMessage = "Pred touto operaciou je potrebne ulozit vykonane zmeny v projekte. Chcete ulozit zmeny a pokracovat v operacii?"
                                LsQuestionCaption = "Ulozenie zmien v projekte"
                            Else
                                LsQuestionMessage = ""
                                LsQuestionCaption = ""
                            End If
                        End If

                        If LbSaveVersions Or LbSaveSolution Then
                            If MessageBox.Show(LsQuestionMessage, LsQuestionCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                                If LbSaveVersions Then
                                    OoAction.Action = GeAction.kkaModSaveAllAmodFilesAndTheirVersions
                                    LeResult = Execute(OoAction)
                                    OoAction.Action = GeAction.kkaModExportAmodSolutionToProject
                                End If

                                If LbSaveSolution Then
                                    OoAction.Action = GeAction.kkaModSolutionSaveFile
                                    LeResult = Execute(OoAction)
                                    OoAction.Action = GeAction.kkaModExportAmodSolutionToProject
                                End If
                            Else
                                LeResult = GeActionResult.kkCancel
                            End If
                        End If

                        If LeResult = GeActionResult.kkOk Then
                            Dim LoModulesAtributesList As List(Of Framework.ModulAtributes) = MoDSaModSolutionFile.GetModulesAtributesForProjectGenerating

                            Dim LoGeneratorFormularov = New formulare.GeneratorFormularov(frmMainForm.ApplicationPaths.FormTemplatesDir, New AMod2.Dat("IBAPREGENEROVANIEVSPROJEKTU", "IBAPREGENEROVANIEVSPROJEKTU", "IBAPREGENEROVANIEVSPROJEKTU"))
                            'show wizard for the setting of export settings
                            Dim LofrmWizardNastavenia As formulare.FrmWizardNastavenia = New formulare.FrmWizardNastavenia(LoGeneratorFormularov, "Zoznamovy Form", frmMainForm.ApplicationPaths.FormsExportSettings)
                            LofrmWizardNastavenia.ShowDialog()
                            Dim LoMain As Framework.Main = New Framework.Main(frmMainForm.ApplicationPaths.TemplatesDir, Nothing, MoDSaModSolutionFile.GetSolutionDirectory, MoDSaModSolutionFile.GetSolutionName, New formulare.ExportSettings(frmMainForm.ApplicationPaths.FormsExportSettings))
                            LoMain.GenerateProject(LoModulesAtributesList, LoModulesAtributesList, "")
                        End If
                Case GeAction.kkamodExportUnitsToForms
                        'if there is any unit
                        If AmodVersion.DSaModVersion.UnitsTable.Rows.Count > 0 Then
                            Dim LoDfrmExportUnitsToForms As ClsDfrmExportUnitsToForms = New ClsDfrmExportUnitsToForms
                            LeResult = LoDfrmExportUnitsToForms.Execute(OoAction)

                            If LeResult = GeActionResult.kkOk Then
                                If AmodVersion.WasModified Then
                                    If MessageBox.Show("Pred touto operaciou je potrebne ulozit neulozene zmeny v danej verzii. Chcete ulozit zmeny a pokracovat v operacii?", "Ulozenie zmien vo verzii", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                                        OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                        LeResult = Execute(OoAction)
                                        OoAction.Action = GeAction.kkamodExportUnitsToForms
                                    Else
                                        LeResult = GeActionResult.kkCancel
                                    End If
                                End If

                                'export units
                                Dim LbNeedToShowWizard As Boolean = True 'only for first editacny form is needed to show wizard
                                Dim LoMarkedUnits As Dictionary(Of String, String) = OoAction.GetData("UNITSFOREXPORT") 'units with formular paths for export
                                Dim LoGeneratorFormularov = New formulare.GeneratorFormularov(frmMainForm.ApplicationPaths.FormTemplatesDir, MoDSaModFile.Dat)
                                For Each LoKeyValuePair As KeyValuePair(Of String, String) In LoMarkedUnits
                                    If LeResult = GeActionResult.kkOk Then
                                        If LoKeyValuePair.Key = "!Generovanie zoznamoveho formularu" Then
                                            'generate zoznamovy form
                                            LoGeneratorFormularov.ExportujZoznamovyFormular("Zoznamovy Form", LoKeyValuePair.Value, New formulare.ExportSettings(frmMainForm.ApplicationPaths.FormsExportSettings), AmodVersion.GetVersionVID, "frmZoznam")
                                        Else
                                            If LbNeedToShowWizard Then
                                                'show wizard for the setting of export settings
                                                Dim LofrmWizardNastavenia As formulare.FrmWizardNastavenia = New formulare.FrmWizardNastavenia(LoGeneratorFormularov, "Zoznamovy Form", frmMainForm.ApplicationPaths.FormsExportSettings)
                                                LofrmWizardNastavenia.ShowDialog()
                                                LbNeedToShowWizard = False
                                            End If
                                            'generate editacny form
                                            LoGeneratorFormularov.Exportuj(LoKeyValuePair.Key, LoKeyValuePair.Value, New formulare.ExportSettings(frmMainForm.ApplicationPaths.FormsExportSettings), AmodVersion.GetVersionVID)
                                        End If
                                    End If
                                Next
                            End If
                        Else
                            MessageBox.Show("Verzia modulu neobsahuje ziadne formulare na generovanie. Vytvorte aspon jeden formular s triedou a spustite generovanie opat.", "Ziadne formulare na generovanie", MessageBoxButtons.OK, MessageBoxIcon.Information)
                        End If
                Case GeAction.kkaModExportModuleToXmod
                        Dim LiVersion As Integer = OoAction.GetData("VERSIONFOREXPORT")
                        Dim LoDSaModFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(MoDSaModFile.Path)
                        Dim LbSaveVersion As Boolean = GetAllUnsavedVersionsOfAmodFile(LoDSaModFile.Path).Contains(LiVersion)


                        If LbSaveVersion Then
                            Dim LoTab As ClsUcnTabPage = MoTabControl.GetTabClassDiagram(LoDSaModFile.Path, LiVersion)
                            If MessageBox.Show("Pred touto operaciou je potrebne ulozit neulozene zmeny v danej verzii. Chcete ulozit zmeny a pokracovat v operacii?", "Ulozenie zmien vo verzii", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                                OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                LeResult = LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                OoAction.Action = GeAction.kkaModExportModuleToXmod
                            Else
                                LeResult = GeActionResult.kkCancel
                            End If
                        End If

                        If LeResult = GeActionResult.kkOk Then
                            Dim frmExportToXmod As AMod2.FrmExportToXMod = New AMod2.FrmExportToXMod(LoDSaModFile.Dat, LoDSaModFile.aModFileDirectory, LoDSaModFile.GetLastVersionModuleName & ".xMod", LiVersion)
                            frmExportToXmod.ShowDialog()
                        End If
                Case GeAction.kkaModImportModuleFromXmod
                        Dim LsAmodPath As String = OoAction.GetData("AMODPATHFORIMPORT")
                        Dim LiVersion As Integer = OoAction.GetData("VERSIONFORIMPORT")
                        Dim LbSaveVersion As Boolean = GetAllUnsavedVersionsOfAmodFile(LsAmodPath).Contains(LiVersion)
                        Dim LoDSaModFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodPath)

                        If LbSaveVersion Then
                            Dim LoTab As ClsUcnTabPage = MoTabControl.GetTabClassDiagram(LsAmodPath, LiVersion)
                            If MessageBox.Show("Pri importe budu niektore informacie pouzite z poslednej verzie (verzia " & LiVersion & "). Pred touto operaciou je potrebne ulozit neulozene zmeny v danej verzii. Chcete ulozit zmeny a pokracovat v operacii?", "Ulozenie zmien vo verzii", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                                OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                LeResult = LoTab.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                OoAction.Action = GeAction.kkaModExportModuleToXmod
                            Else
                                LeResult = GeActionResult.kkCancel
                            End If
                        End If

                        If LeResult = GeActionResult.kkOk Then
                            'change collection to list
                            Dim LoCollectionOfAllModuleNames As Collection = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAllModuleNames
                            Dim LoListOfAllModuleNames As List(Of String) = New List(Of String)
                            For Each LsString As String In LoCollectionOfAllModuleNames
                                LoListOfAllModuleNames.Add(LsString)
                            Next

                            Dim frmImportFromXMod As AMod2.FrmImportFromXMod = New AMod2.FrmImportFromXMod(LoDSaModFile.Dat, LoDSaModFile.aModFileDirectory, LoListOfAllModuleNames)
                            frmImportFromXMod.ShowDialog()

                            If frmImportFromXMod.IsSuccessfullImported Then
                                'refresh joined modules in modul
                                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshJoinedModulesInModule(LoDSaModFile)
                                'refreshes joined modules links within main tab diagram
                                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshJoinedModulesLinksOfChildModule(LoDSaModFile.GetLastVersionModuleName)
                                'refresh captions and tips of tabs with opened versions from aMod file
                                RefreshCaptionAndTipOfTabsOfAmodFile(LoDSaModFile.Path)

                                If LeResult = GeActionResult.kkOk Then
                                    If MessageBox.Show("Uspesne bola importovana najnovsia verzia " & LoDSaModFile.Dat.GetLastVersion & ". Zelate si ju otvorit na novej zalozke?", "Uspesne importovana verzia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                                        Dim LoVersionToOpen As Collection = New Collection
                                        LoVersionToOpen.Add(LoDSaModFile.Dat.GetLastVersion)

                                        OoAction.SetData(LoVersionToOpen, "VERSIONS")
                                        OoAction.SetData("TEMP NAME", "MODULENAME")
                                        OoAction.SetData(LoDSaModFile.Path, "PATHTOFILE")
                                        OoAction.Action = GeAction.kkaModTryToOpenVersions
                                        LeResult = Execute(OoAction)
                                        OoAction.Action = GeAction.kkamodPromoteVersion
                                    End If
                                End If
                            End If
                        End If
                Case GeAction.kkamodImportUnitsFromForms
                        'if there is any unit
                        If AmodVersion.DSaModVersion.UnitsTable.Rows.Count > 0 Then
                            Dim LoDfrmImportUnitsFromForms As ClsDfrmImportUnitsFromForms = New ClsDfrmImportUnitsFromForms
                            LeResult = LoDfrmImportUnitsFromForms.Execute(OoAction)

                            If LeResult = GeActionResult.kkOk Then
                                Dim LoMarkedUnits As Dictionary(Of String, String) = OoAction.GetData("UNITSFORIMPORT") 'units with formular paths for import

                                'import new units
                                Dim LoGeneratorFormularov As formulare.GeneratorFormularov = New formulare.GeneratorFormularov(frmMainForm.ApplicationPaths.FormTemplatesDir, MoDSaModFile.Dat)
                                If LoGeneratorFormularov.Importuj(LoMarkedUnits, AmodVersion.DSaModVersion) = True Then
                                    SetFileWasModified(True)
                                    For Each LoKeyValuePair As KeyValuePair(Of String, String) In LoMarkedUnits
                                        'rebuild all tables from actual unit
                                    Dim LoIncludedTablesRows As DataRow() = MoAmodVersion.DSaModVersion.TableListTable.Select(String.Format("{0}='{1}' AND {2}={3}", AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName, LoKeyValuePair.Key, KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.TableType, CInt(KrosLib.Data.eTableType.DataTable)))
                                        'iterate tables from unit and rebuild them
                                        For Each LoIncludedTablesRow As DataRow In LoIncludedTablesRows
                                            Dim LsAppTableName As String = LoIncludedTablesRow(KrosLib.Editors.xModDataSet.TableSysnames.TableList.Columns.AppTableName)
                                            Dim LoMMTableNode As ClsMMTableNode = GetTableFromDiagramByTableName(LsAppTableName, fcDiagram)
                                            LoMMTableNode.MMRebuildTable(AmodVersion.GetDataTableAllRowsSortedByPosition(LsAppTableName))
                                        Next
                                    Next
                                End If
                            End If
                        Else
                            MessageBox.Show("Verzia modulu neobsahuje ziadne formulare, do ktorych by sa importovalo. Vytvorte aspon jeden formular s triedou a spustite import opat.", "Ziadne formulare na import", MessageBoxButtons.OK, MessageBoxIcon.Information)
                        End If
                Case GeAction.kkaModUpdateHumanModuleName
                        Dim LoDSamodFile As ClsDSaModFile = OoAction.GetData("AMODFILE")
                        Dim LsNewHumanModuleName As String = OoAction.GetData("NEWHUMANMODULENAME")

                        Dim LsModuleName As String = LoDSamodFile.GetLastVersionModuleName
                        Dim LsOldHumanModuleName As String = LoDSamodFile.GetLastVersionHumanModuleName

                        'Im changing human module name so I need to change also human module names of all versions in aMod file and rename aMod file/folder

                        'rename module in aMod solution file + also with saving a file
                        LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.UpdateHumanModuleName(LsOldHumanModuleName, LsNewHumanModuleName)
                        If LeResult = GeActionResult.kkOk Then
                            'rename all modules in aMod file + also with saving a file
                            LeResult = LoDSamodFile.UpdateHumanModuleNamesOfAllVersions(LsNewHumanModuleName)
                            Select Case LeResult
                                Case GeActionResult.kkOk
                                    'change human module name also in diagram of main tab
                                    Dim LoModuleNode As ClsMMModuleNode = GetModuleFromDiagramByModuleName(LsModuleName, MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram)
                                    LoModuleNode.Text = LsNewHumanModuleName
                                    'since there was a change also in diagram I need to save also diagram, so I cant call only MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.SaveFile(False)
                                    OoAction.Action = GeAction.kkaModSolutionSaveFile
                                    LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                    OoAction.Action = GeAction.kkaModUpdateHumanModuleName

                                    'refreshes panel in main tab with table columns info joined to module
                                    RefreshTableColumnsJoinedToModule(LsModuleName, "", "", "")
                                    'refresh captions and tips of tabs with opened versions from aMod file
                                    RefreshCaptionAndTipOfTabsOfAmodFile(LoDSamodFile.Path)
                                    'refresh ComboboxJoinedModule
                                    MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.FillComboboxJoinedModule()
                                    'refreshing selected item of diagrams of all tabs
                                    RefreshSelectedItemsOfAllTabs()
                                Case GeActionResult.kkError
                                    'rename all modules in aMod file back + also with saving a file
                                    ' ''LoDSamodFile.UpdateHumanModuleNamesOfAllVersions(LsOldHumanModuleName)
                                    'rename module in aMod solution file back + also with saving a file
                                    ' ''MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.UpdateHumanModuleName(LsNewHumanModuleName, LsOldHumanModuleName)
                                    ' ''LeResult = GeActionResult.kkError
                            End Select
                        Else
                            'rename module in aMod solution file back + also with saving a file
                            ' ''MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.UpdateHumanModuleName(LsNewHumanModuleName, LsOldHumanModuleName)
                            ' ''LeResult = GeActionResult.kkError
                        End If
                Case GeAction.kkaModUpdateModuleName
                        Dim LoDSamodFile As ClsDSaModFile = OoAction.GetData("AMODFILE")
                        Dim LsNewModuleName As String = OoAction.GetData("NEWMODULENAME")
                        Dim LsOldModuleName As String = LoDSamodFile.GetLastVersionModuleName
                        Dim LsOldAmodFilePath As String = LoDSamodFile.Path
                        Dim LsNewAmodFilePath As String = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAmodFilePath(LsNewModuleName)

                        If LsNewModuleName <> "" Then
                            'Im changing module name so I need to change also module names of all versions in aMod file

                            'rename module in aMod solution file + also with saving a file
                            LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.UpdateModuleName(LsOldModuleName, LsNewModuleName)
                            Select Case LeResult
                                Case GeActionResult.kkOk
                                    'rename all modules in aMod file + also with saving a file
                                    LeResult = LoDSamodFile.UpdateModuleNamesOfAllVersions(LsNewModuleName, LsNewAmodFilePath)
                                    Select Case LeResult
                                        Case GeActionResult.kkOk
                                            'rename joined module of child modules
                                            LeResult = RenameJoinedModuleOfChildModules(LsOldModuleName, LsNewModuleName)
                                            If LeResult = GeActionResult.kkOk Then
                                                'change module name also in diagram of main tab
                                                Dim LoModuleNode As ClsMMModuleNode = GetModuleFromDiagramByModuleName(LsOldModuleName, MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram)
                                                LoModuleNode.ModuleName = LsNewModuleName
                                                'since there was a change also in diagram I need to save also diagram, so I cant call only MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.SaveFile(False)
                                                OoAction.Action = GeAction.kkaModSolutionSaveFile
                                                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                                OoAction.Action = GeAction.kkaModUpdateHumanModuleName

                                                If LeResult = GeActionResult.kkOk Then
                                                    'change key in collection of opened aMod files if aMod file is opened
                                                    If MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetCollection.Contains(LsOldAmodFilePath) Then
                                                        MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.ChangeKeyOfItem(LsOldAmodFilePath, LsNewAmodFilePath)
                                                    End If
                                                End If
                                                'refreshes panel in main tab with table columns info joined to module
                                                RefreshTableColumnsJoinedToModule(LsOldModuleName, "", "", "")
                                            End If

                                            'fills MoUcnComboboxJoinedModule in main tab with all modules from aMod solution
                                            MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.FillComboboxJoinedModule()
                                            'refresh captions and tips of tabs with opened versions from aMod file
                                            RefreshCaptionAndTipOfTabsOfAmodFile(LoDSamodFile.Path)
                                            'refreshing selected item of diagrams of all tabs
                                            RefreshSelectedItemsOfAllTabs()
                                        Case GeActionResult.kkError
                                            'rename all modules in aMod file back + also with saving a file
                                            ' ''LoDSamodFile.UpdateModuleNamesOfAllVersions(LsOldModuleName, LsOldAmodFilePath)
                                            'rename module in aMod solution file back + also with saving a file
                                            ' ''MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.UpdateModuleName(LsNewModuleName, LsOldModuleName, False)
                                            ' ''LeResult = GeActionResult.kkError
                                    End Select
                                Case GeActionResult.kkError
                                    'rename module in aMod solution file back + also with saving a file
                                    ' ''MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.UpdateModuleName(LsNewModuleName, LsOldModuleName)
                                    ' ''LeResult = GeActionResult.kkError
                            End Select
                        Else
                            MessageBox.Show("Programatorsky nazov modulu nesmie byt prazdny retazec!" & vbNewLine & vbNewLine & "Programatorsky nazov moze obsahovat iba male a velke pismena abecedy, znak ""_"" a cisla nie na zaciatku nazvu. Po prisposobeni Vami zadaneho nazvu je vsak vysledkom prazdny retazec.", "Neprijatelny programatorsky nazov modulu", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                            LeResult = GeActionResult.kkError
                        End If
                Case GeAction.kkaModSolutionUpdateSolutionName
                        LeResult = MoDSaModSolutionFile.UpdateSolutionName(OoAction.GetData("NEWSOLUTIONNAME"))
                        If LeResult = GeActionResult.kkOk Then
                            Dim LsModuleName As String = ""
                            Dim LsAmodFileNewPath As String = ""
                            Dim LsAmodFileOldPath As String = ""
                            'change paths of all aMod files, all relative paths of aMod files in DSaModSolutionFile and all keys in collection of opened aMod files
                            'I need to create another collection coz Im going to change paths of aMod files in OpenedAmodFiles collection and there was infinite loop!
                            Dim LoOpenedAmodFilesPaths As Collection = New Collection
                            For Each LoOpenedAmodFile As ClsDSaModFile In MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetCollection
                                LoOpenedAmodFilesPaths.Add(LoOpenedAmodFile.Path)
                            Next

                            Dim LoDSaModFile As ClsDSaModFile = Nothing
                            For Each LsAmodFilePath As String In LoOpenedAmodFilesPaths
                                LoDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodFilePath)
                                LsModuleName = LoDSaModFile.GetLastVersionModuleName
                                LsAmodFileOldPath = LoDSaModFile.Path
                                LsAmodFileNewPath = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAmodFilePath(LsModuleName)
                                LoDSaModFile.SetNewFilePath(LsAmodFileNewPath)
                                MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.UpdateRelativePathOfaModFile(LsModuleName, MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetRelativePathOfModuleFile(LsModuleName))
                                MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.ChangeKeyOfItem(LsAmodFileOldPath, LsAmodFileNewPath)
                            Next
                        End If

                        'refresh caption of a form
                        MakeCaptionOfForm()
                        'refresh captions and tips of all tabs
                        RefreshCaptionAndTipOfAllTabs()
                Case GeAction.kkaModSolutionAddJoinedModuleOfTableColumn
                        LeResult = AddJoinedModule(OoAction.GetData("ORIGINALMODULENAME"), OoAction.GetData("NEWJOINEDMODULENAME"))

                        'save aMod solution
                        OoAction.Action = GeAction.kkaModSolutionSaveFile
                        LeResult = Execute(OoAction)
                        OoAction.Action = GeAction.kkaModSolutionAddJoinedModuleOfTableColumn
                Case GeAction.kkaModSolutionRemoveJoinedModuleOfTableColumn
                        LeResult = RemoveJoinedModule(OoAction.GetData("ORIGINALMODULENAME"), OoAction.GetData("JOINEDMODULENAMEFORREMOVE"))

                        'save aMod solution
                        OoAction.Action = GeAction.kkaModSolutionSaveFile
                        LeResult = Execute(OoAction)
                        OoAction.Action = GeAction.kkaModSolutionRemoveJoinedModuleOfTableColumn
                Case GeAction.kkAddItemToDiagram
                        Dim LoNode As DiagramItem = OoAction.GetData("ITEM")
                        Dim LsTypeOfNode As String = LoNode.GetType.Name
                        Select Case LsTypeOfNode
                            Case "ClsMMContainerNode"
                                Dim LoMMContainerNode As ClsMMContainerNode = CType(LoNode, ClsMMContainerNode)
                                OoAction.Action = GeAction.kkAddContainerToDiagram
                                OoAction.SetData(LoMMContainerNode, "CONTAINER")
                                LeResult = Execute(OoAction)
                            Case "ClsMMTableNode"
                                Dim LoMMTableNode As ClsMMTableNode = CType(LoNode, ClsMMTableNode)
                                OoAction.Action = GeAction.kkAddTableToDiagram
                                OoAction.SetData(LoMMTableNode, "TABLE")
                                LeResult = Execute(OoAction)
                            Case "ClsMMNoteNode"
                                Dim LoMMNoteNode As ClsMMNoteNode = CType(LoNode, ClsMMNoteNode)
                                OoAction.Action = GeAction.kkAddNoteToDiagram
                                OoAction.SetData(LoMMNoteNode, "SHAPENODE")
                                LeResult = Execute(OoAction)
                            Case "ClsMMModuleNode"
                                Dim LoMMModuleNode As ClsMMModuleNode = CType(LoNode, ClsMMModuleNode)
                                OoAction.Action = GeAction.kkAddModuleToDiagram
                                OoAction.SetData(LoMMModuleNode, "MODULE")
                                LeResult = Execute(OoAction)
                            Case "ClsMMActorNode"
                                Dim LoMMActorNode As ClsMMActorNode = CType(LoNode, ClsMMActorNode)
                                OoAction.Action = GeAction.kkAddActorToDiagram
                                OoAction.SetData(LoMMActorNode, "ACTOR")
                                LeResult = Execute(OoAction)
                            Case "ClsMMActivityNode"
                                Dim LoMMActivityNode As ClsMMActivityNode = CType(LoNode, ClsMMActivityNode)
                                OoAction.Action = GeAction.kkAddActivityToDiagram
                                OoAction.SetData(LoMMActivityNode, "ACTIVITY")
                                LeResult = Execute(OoAction)
                            Case "ClsMMSystemBoundaryNode"
                                Dim LoMMSystemBoundaryNode As ClsMMSystemBoundaryNode = CType(LoNode, ClsMMSystemBoundaryNode)
                                OoAction.Action = GeAction.kkAddSystemBoundaryToDiagram
                                OoAction.SetData(LoMMSystemBoundaryNode, "SYSTEMBOUNDARY")
                                LeResult = Execute(OoAction)
                            Case Else
                                Debug.Print("CHYBA!!! - Execute - ACTION - kkItemAddedToDiagram")
                                LeResult = GeActionResult.kkError
                        End Select
                        OoAction.Action = GeAction.kkAddItemToDiagram
                Case GeAction.kkAddContainerToDiagram
                        Dim LsNewUnitName As String = ""
                        Dim LsNewHumanUnitName As String = ""
                        Dim LoMMContainerNode As ClsMMContainerNode = OoAction.GetData("CONTAINER")

                        LeResult = AmodVersion.InsertNewUnit(OoAction.GetData("ORIGINALCONTAINERNAME"), OoAction.GetData("ORIGINALHUMANCONTAINERNAME"), LsNewUnitName, LsNewHumanUnitName)
                        If LeResult = GeActionResult.kkOk Then
                            'set ID
                            LoMMContainerNode.ID = AmodVersion.GetUnitID(LsNewUnitName)
                            'container was successfully added
                            LoMMContainerNode.UnitName = LsNewUnitName
                        LoMMContainerNode.Caption = LsNewHumanUnitName
                        'add container to diagram
                        Me.fcDiagram.Nodes.Add(LoMMContainerNode)
                        'add central table
                            Dim LoMMTableNode As ClsMMTableNode = New ClsMMTableNode(Me.fcDiagram)
                            'resize container size
                            LoMMContainerNode.MMResizeAllToFitContainer()
                            'set position of table in container
                            LoMMTableNode.Bounds = New RectangleF(LoMMContainerNode.Bounds.X + LoMMContainerNode.Margin, LoMMContainerNode.Bounds.Y + LoMMContainerNode.Margin + LoMMContainerNode.CaptionHeight, LoMMTableNode.Bounds.Width, LoMMTableNode.Bounds.Height)

                            OoAction.Action = GeAction.kkAddTableToDiagram
                            OoAction.SetData(LoMMTableNode, "TABLE")
                            LeResult = Execute(OoAction)
                            OoAction.Action = GeAction.kkAddContainerToDiagram
                        End If
                Case GeAction.kkAddTableToDiagram
                        Dim LsNewAppTableName As String = ""
                        Dim LsNewHummanTableName As String = ""
                        Dim LoMMTableNode As ClsMMTableNode = OoAction.GetData("TABLE")
                        Dim LoMMContainerNode As ClsMMContainerNode = OoAction.GetData("CONTAINER")
                    LeResult = AmodVersion.InsertNewDataTable(OoAction.GetData("ORIGINALAPPTABLENAME"), OoAction.GetData("ORIGINALHUMANTABLENAME"), LoMMContainerNode.UnitName, LsNewAppTableName, LsNewHummanTableName)
                        If LeResult = GeActionResult.kkOk Then
                            'set ID
                            LoMMTableNode.ID = AmodVersion.GetTableID(LsNewAppTableName)
                            'table was successfully added
                            LoMMTableNode.AppTableName = LsNewAppTableName
                            LoMMTableNode.Caption = LsNewHummanTableName
                            'rebuild table, coz of new PK column
                        LoMMTableNode.MMRebuildTable(AmodVersion.GetDataTableAllRowsSortedByPosition(LoMMTableNode.AppTableName))
                        'add table to diagram
                        Me.fcDiagram.Nodes.Add(LoMMTableNode)
                        
                        SetFileWasModified(True)
                        'add table to container
                        LoMMContainerNode.MMAddNodeToContainerProgrammatically(LoMMTableNode)
                        'create NodeForNewLink
                        Dim LoMMNodeForNewLink As ClsMMNodeForNewLink = New ClsMMNodeForNewLink(LoMMTableNode.Bounds)
                        Me.fcDiagram.Nodes.Add(LoMMNodeForNewLink)
                        LoMMNodeForNewLink.AttachTo(LoMMTableNode, AttachToNode.TopRight)
                        LoMMNodeForNewLink.Visible = False 'after attaching, visibility is changed to true
                        LoMMTableNode.SubordinateGroup.AutoDeleteItems = True
                        End If
                Case GeAction.kkAddNoteToDiagram
                        Dim LoMMNoteNode As ClsMMNoteNode = OoAction.GetData("SHAPENODE")
                        Select Case MoTabPage.TypeOfTab
                            Case GeTypeOfTab.kkClassDiagramTab
                                'insert new note to DS and also set ID
                                LeResult = AmodVersion.InsertNewNote(LoMMNoteNode.Text, LoMMNoteNode.ID)
                            Case Else
                                'do nothing
                        End Select

                        If LeResult = GeActionResult.kkOk Then
                            'add ShapeNode to diagram
                        Me.fcDiagram.Nodes.Add(LoMMNoteNode)
                        'create NodeForNewLink
                        Dim LoMMNodeForNewLink As ClsMMNodeForNewLink = New ClsMMNodeForNewLink(LoMMNoteNode.Bounds)
                        Me.fcDiagram.Nodes.Add(LoMMNodeForNewLink)
                        LoMMNodeForNewLink.AttachTo(LoMMNoteNode, AttachToNode.TopRight)
                        LoMMNodeForNewLink.Visible = False 'after attaching, visibility is changed to true
                        LoMMNoteNode.SubordinateGroup.AutoDeleteItems = True
                        End If
                Case GeAction.kkAddModuleToDiagram
                        'create aMod file first
                        Dim LsOldModuleName As String = OoAction.GetData("ORIGINALMODULENAME")
                        Dim LsNewModuleName As String = ""
                        Dim LsNewHumanModuleName As String = ""
                        LsNewModuleName = MoDSaModSolutionFile.MakeNextUniqueModuleName(LsOldModuleName)
                        LsNewHumanModuleName = MoDSaModSolutionFile.MakeNextUniqueHumanModuleName(LsOldModuleName)

                        OoAction.Action = GeAction.kkaModCreateVirginFile
                        OoAction.SetData(LsNewModuleName, "MODULENAME")
                        OoAction.SetData(LsNewHumanModuleName, "HUMANMODULENAME")
                        OoAction.SetData(MoDSaModSolutionFile.GetAmodFilePath(LsNewModuleName), "AMODPATH")
                        LeResult = Execute(OoAction)
                        OoAction.Action = GeAction.kkAddModuleToDiagram

                        'if aMod file was created
                        If LeResult = GeActionResult.kkOk Then
                            Dim LoMMModuleNode As ClsMMModuleNode = OoAction.GetData("ITEM")
                            LeResult = MoDSaModSolutionFile.InsertNewModule(LsNewModuleName, LsNewHumanModuleName)
                            If LeResult = GeActionResult.kkOk Then
                                'module was successfully added
                                LoMMModuleNode.Text = LsNewHumanModuleName
                                LoMMModuleNode.ModuleName = LsNewModuleName
                                'add module to diagram
                            Me.fcDiagram.Nodes.Add(LoMMModuleNode)
                            'since there was a change also in diagram I need to save also diagram, so I cant call only MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.SaveFile(False)
                                OoAction.Action = GeAction.kkaModSolutionSaveFile
                                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                OoAction.Action = GeAction.kkAddModuleToDiagram

                                'fills MoUcnComboboxJoinedModule in main tab with all modules from aMod solution
                                MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.FillComboboxJoinedModule()
                                'refreshing selected item of diagrams of all tabs
                                RefreshSelectedItemsOfAllTabs()
                            End If
                        End If
                Case GeAction.kkAddLinkToDiagram
                        Dim LoLink As ClsMMLinkNode = OoAction.GetData("LINK")
                        Dim LoMMOriginTableNode As ClsMMTableNode = CType(LoLink.Origin, ClsMMTableNode)
                        Dim LoMMDestinationTableNode As ClsMMTableNode = CType(LoLink.Destination, ClsMMTableNode)
                        LeResult = AmodVersion.InsertNewRelationshipToHierarchy(LoMMOriginTableNode.AppTableName, LoMMOriginTableNode.Caption, LoMMDestinationTableNode.AppTableName, LoLink.MMRelationType)
                        'rebuil table in all cases (LeResult = whatever) coz of FK was added
                        LoMMDestinationTableNode.MMRebuildTable(AmodVersion.GetDataTableAllRowsSortedByPosition(LoMMDestinationTableNode.AppTableName))
                Case GeAction.kkAddColumnToTable
                        Dim LoMMTableNode As ClsMMTableNode = OoAction.GetData("TABLE")
                        Dim LsTableName As String = LoMMTableNode.AppTableName
                        Dim LsOriginalColumnName As String = OoAction.GetData("ORIGINALCOLUMNNAME")
                        Dim LsOriginalHumanColumnName As String = OoAction.GetData("ORIGINALHUMANCOLUMNNAME")
                        Dim LsNewColumnName As String = ""
                        Dim LiPositionOfColumn As Integer = OoAction.GetData("POSITIONOFCOLUMN")
                        LeResult = AmodVersion.InsertNewColumnToTable(LsTableName, LsOriginalColumnName, LsOriginalHumanColumnName, LsNewColumnName, LiPositionOfColumn)
                        'resize table in all cases (LeResult = whatever)
                    LoMMTableNode.MMRebuildTable(AmodVersion.GetDataTableAllRowsSortedByPosition(LoMMTableNode.AppTableName))
                    LoMMTableNode.HighlightedRow = LoMMTableNode.Rows.Count - 1
                Case GeAction.kkAddActorToDiagram
                    Dim LoMMActorNode As ClsMMActorNode = OoAction.GetData("ACTOR")
                    Me.fcDiagram.Nodes.Add(LoMMActorNode)
                    'create NodeForNewLink - so it has index 0 in SubordinateGroup
                    Dim LoMMNodeForNewLink As ClsMMNodeForNewLink = New ClsMMNodeForNewLink(LoMMActorNode.Bounds)
                    Me.fcDiagram.Nodes.Add(LoMMNodeForNewLink)
                    LoMMNodeForNewLink.AttachTo(LoMMActorNode, AttachToNode.TopRight)
                    LoMMNodeForNewLink.Visible = False 'after attaching, visibility is changed to true
                    'create attached text node - so it has index 1 in SubordinateGroup
                    Dim LoMMTextNode As ClsMMTextNode = New ClsMMTextNode(OoAction.GetData("ORIGINALACTORNAME"), LoMMActorNode.Bounds)
                    Me.fcDiagram.Nodes.Add(LoMMTextNode)
                    LoMMTextNode.AttachTo(LoMMActorNode, AttachToNode.BottomCenter)
                    LoMMActorNode.SubordinateGroup.AutoDeleteItems = True
                    SetFileWasModified(True)
                Case GeAction.kkAddActivityToDiagram
                        Dim LoMMActivityNode As ClsMMActivityNode = OoAction.GetData("ACTIVITY")
                        LoMMActivityNode.Text = OoAction.GetData("ORIGINALACTIVITYNAME")
                        'add ActivityNode to diagram
                    Me.fcDiagram.Nodes.Add(LoMMActivityNode)
                    'create NodeForNewLink
                    Dim LoMMNodeForNewLink As ClsMMNodeForNewLink = New ClsMMNodeForNewLink(LoMMActivityNode.Bounds)
                    Me.fcDiagram.Nodes.Add(LoMMNodeForNewLink)
                    LoMMNodeForNewLink.AttachTo(LoMMActivityNode, AttachToNode.TopRight)
                    LoMMNodeForNewLink.Visible = False 'after attaching, visibility is changed to true
                    LoMMActivityNode.SubordinateGroup.AutoDeleteItems = True
                        SetFileWasModified(True)
                Case GeAction.kkAddSystemBoundaryToDiagram
                        Dim LoMMSystemBoundaryNode As ClsMMSystemBoundaryNode = OoAction.GetData("SYSTEMBOUNDARY")
                        LoMMSystemBoundaryNode.Caption = OoAction.GetData("ORIGINALSYSTEMBOUNDARYNAME")
                        'add ActivityNode to diagram
                        Me.fcDiagram.Nodes.Add(LoMMSystemBoundaryNode)
                        SetFileWasModified(True)
                Case GeAction.kkaModMoveUpColumnOfTable
                        Dim LoMMTableNode As ClsMMTableNode = OoAction.GetData("TABLE")
                        Dim LiRowIndex As Integer = OoAction.GetData("ROWINDEX")
                        LeResult = AmodVersion.UpdateUpColumnPosition(LoMMTableNode.AppTableName, LiRowIndex)
                        LoMMTableNode.MMRebuildTable(AmodVersion.GetDataTableAllRowsSortedByPosition(LoMMTableNode.AppTableName))
                Case GeAction.kkaMOdMoveDownColumnOfTable
                        Dim LoMMTableNode As ClsMMTableNode = OoAction.GetData("TABLE")
                        Dim LiRowIndex As Integer = OoAction.GetData("ROWINDEX")
                        LeResult = AmodVersion.UpdateDownColumnPosition(LoMMTableNode.AppTableName, LiRowIndex)
                        LoMMTableNode.MMRebuildTable(AmodVersion.GetDataTableAllRowsSortedByPosition(LoMMTableNode.AppTableName))
                Case GeAction.kkRemoveColumnFromTable
                        Dim LoMMTableNode As ClsMMTableNode = OoAction.GetData("TABLE")
                        Dim LsTableName As String = LoMMTableNode.AppTableName
                        Dim LsColumnName As String = OoAction.GetData("COLUMNNAME")
                        Dim LbIsColumnJoinedToModule As Boolean = AmodVersion.GetDataTableRowByColumnName(LsTableName, LsColumnName)(KrosLib.Editors.xModDataSet.TableSysnames.DataTable.Columns.JoinModuleID) <> ""
                        LeResult = AmodVersion.DeleteColumnFromTable(LsTableName, LsColumnName)
                        'resize table in all cases (LeResult = whatever)
                        LoMMTableNode.MMRebuildTable(AmodVersion.GetDataTableAllRowsSortedByPosition(LoMMTableNode.AppTableName))

                        If LbIsColumnJoinedToModule Then
                            'if column was joined to any module Im going to refresh joined links and other things in main tab so I need to save this change in aMod version
                            OoAction.Action = GeAction.kkaModSaveVersionAndFile
                            Execute(OoAction)
                            OoAction.Action = GeAction.kkRemoveColumnFromTable

                            'refreshes joined modules links within main tab diagram
                            MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshJoinedModulesLinksOfChildModule(DSaModFile.GetLastVersionModuleName)
                        End If

                        'refreshes panel in main tab with table columns info joined to module
                        If IsThisTheLastVersion Then RefreshTableColumnsJoinedToModule(DSaModFile.GetLastVersionModuleName, MoAmodVersion.GetTableListRowByAppTableName(LoMMTableNode.AppTableName)(AMod2.DsAModOneVersion.TableSysnames.TableList.Columns.UnitName), LoMMTableNode.AppTableName, LsColumnName)
                Case GeAction.kkRemoveDiagramSelection
                    If MoTabPage.TypeOfTab <> GeTypeOfTab.kkVersionComparisonTab Then
                        Dim LoTablesCollection As List(Of ClsMMTableNode) = New List(Of ClsMMTableNode)
                        Dim LoContainersCollection As List(Of ClsMMContainerNode) = New List(Of ClsMMContainerNode)
                        Dim LoNotesCollection As List(Of ClsMMNoteNode) = New List(Of ClsMMNoteNode)
                        Dim LoModulesCollection As List(Of ClsMMModuleNode) = New List(Of ClsMMModuleNode)
                        Dim LoRelationshipLinksCollection As List(Of ClsMMLinkNode) = New List(Of ClsMMLinkNode)
                        Dim LoNoteLinksCollection As List(Of ClsMMLinkNode) = New List(Of ClsMMLinkNode)
                        Dim LoUCDnodesCollection As List(Of Object) = New List(Of Object)()

                        '**************** removing in selection order ****************
                        ' ''Dim LoItem As DiagramItem
                        '' ''I cant use For Each statement to iterate collection coz Im changing collection items indirectly (for ex. table is also removed, when container is removed, or links or...)
                        ' ''While fcDiagram.Selection.Items.Count <> 0
                        ' ''    LoItem = fcDiagram.Selection.Items(0)
                        ' ''    Select Case LoItem.GetType.Name
                        ' ''        Case "ClsMMContainerNode"
                        ' ''            Dim LoMMContainerNode As ClsMMContainerNode = CType(LoItem, ClsMMContainerNode)
                        ' ''            OoAction.Action = GeAction.kkRemoveContainerFromDiagram
                        ' ''            OoAction.SetData(LoMMContainerNode, "NODE")
                        ' ''        Case "ClsMMTableNode"
                        ' ''            Dim LoMMTableNode As ClsMMTableNode = CType(LoItem, ClsMMTableNode)
                        ' ''            OoAction.Action = GeAction.kkRemoveTableFromDiagram
                        ' ''            OoAction.SetData(IIf(ContainerNode.GetContainer(LoMMTableNode).Selected, True, False), "REMOVINGALSOCONTAINER")
                        ' ''            OoAction.SetData(LoMMTableNode, "NODE")
                        ' ''        Case "ClsMMNoteNode"
                        ' ''            Dim LoMMNoteNode As ClsMMNoteNode = CType(LoItem, ClsMMNoteNode)
                        ' ''            OoAction.Action = GeAction.kkRemoveNoteNodeFromDiagram
                        ' ''            OoAction.SetData(LoMMNoteNode, "NODE")
                        ' ''        Case "ClsLinkNode"
                        ' ''            Dim LoMMLinkNode As ClsMMLinkNode = CType(LoItem, ClsMMLinkNode)
                        ' ''            OoAction.Action = GeAction.kkRemoveLinkFromDiagram
                        ' ''            OoAction.SetData(LoMMLinkNode, "LINK")
                        ' ''        Case Else
                        ' ''            Debug.Print("CHYBA!!! - Execute - ACTION - kkDeleteDiagramSelection -   Select Case LoNode.GetType.Name")
                        ' ''    End Select
                        ' ''    LeResult = Execute(OoAction)
                        ' ''    OoAction.Action = GeAction.kkRemoveDiagramSelection

                        ' ''    If LeResult <> GeActionResult.kkOk Then Exit While
                        ' ''End While
                        ' ''OoAction.Action = GeAction.kkRemoveDiagramSelection
                        '**************** removing in selection order ****************

                        '**************** removing in my own order (1. containers, 2. tables...) ****************
                        'filling collections of nodes in selection
                        For Each LoDiagramItem As DiagramItem In fcDiagram.Selection.Items
                            Select Case LoDiagramItem.GetType.Name
                                Case "ClsMMContainerNode"
                                    LoContainersCollection.Add(LoDiagramItem)
                                Case "ClsMMTableNode"
                                    LoTablesCollection.Add(LoDiagramItem)
                                Case "ClsMMNoteNode"
                                    LoNotesCollection.Add(LoDiagramItem)
                                Case "ClsMMLinkNode"
                                    Dim LoMMLinkNode As ClsMMLinkNode = CType(LoDiagramItem, ClsMMLinkNode)
                                    Select Case LoMMLinkNode.MMTypeOfLink
                                        Case GeTypeOfLink.kkClassDiagramRelationship, GeTypeOfLink.kkUseCaseRelationship
                                            LoRelationshipLinksCollection.Add(LoDiagramItem)
                                        Case GeTypeOfLink.kkNote
                                            LoNoteLinksCollection.Add(LoDiagramItem)
                                        Case Else
                                            Debug.Print("CHYBA!!! - Execute - ACTION - kkDeleteDiagramSelection -  Select Case LoMMLinkNode.MMTypeOfLink")
                                    End Select
                                Case "ClsMMModuleNode"
                                    LoModulesCollection.Add(LoDiagramItem)
                                Case "ClsMMActivityNode", "ClsMMActorNode", "ClsMMSystemBoundaryNode"
                                    LoUCDnodesCollection.Add(LoDiagramItem)
                                Case Else
                                    MessageBox.Show("Odstranenie modulu zatial nedostupne :-)", "Makam na tom...", MessageBoxButtons.OK, MessageBoxIcon.Information)
                                    Debug.Print("CHYBA!!! - Execute - ACTION - kkDeleteDiagramSelection -   Select Case LoNode.GetType.Name")
                            End Select
                        Next

                        'removing containers
                        If LeResult = GeActionResult.kkOk Then
                            For Each LoNode As DiagramNode In LoContainersCollection
                                If LeResult = GeActionResult.kkOk AndAlso fcDiagram.Selection.Items.Contains(LoNode) Then
                                    OoAction.Action = GeAction.kkRemoveContainerFromDiagram
                                    OoAction.SetData(LoNode, "NODE")
                                    LeResult = Execute(OoAction)
                                End If
                            Next
                            OoAction.Action = GeAction.kkRemoveDiagramSelection
                        End If

                        'removing tables
                        If LeResult = GeActionResult.kkOk Then
                            For Each LoNode As DiagramNode In LoTablesCollection
                                If LeResult = GeActionResult.kkOk AndAlso fcDiagram.Selection.Items.Contains(LoNode) Then
                                    OoAction.Action = GeAction.kkRemoveTableFromDiagram
                                    OoAction.SetData(False, "REMOVINGALSOCONTAINER") 'FALSE, coz all tables from containers (intended for delete) were already deleted
                                    OoAction.SetData(LoNode, "NODE")
                                    LeResult = Execute(OoAction)
                                End If
                            Next
                            OoAction.Action = GeAction.kkRemoveDiagramSelection
                        End If

                        'removing notes
                        If LeResult = GeActionResult.kkOk Then
                            For Each LoNode As DiagramNode In LoNotesCollection
                                If LeResult = GeActionResult.kkOk AndAlso fcDiagram.Selection.Items.Contains(LoNode) Then
                                    OoAction.Action = GeAction.kkRemoveNoteFromDiagram
                                    OoAction.SetData(LoNode, "NODE")
                                    LeResult = Execute(OoAction)
                                End If
                            Next
                            OoAction.Action = GeAction.kkRemoveDiagramSelection
                        End If

                        'removing relationship links
                        If LeResult = GeActionResult.kkOk Then
                            For Each LoLink As DiagramLink In LoRelationshipLinksCollection
                                If LeResult = GeActionResult.kkOk AndAlso fcDiagram.Selection.Items.Contains(LoLink) Then
                                    OoAction.Action = GeAction.kkRemoveLinkFromDiagram
                                    OoAction.SetData(LoLink, "LINK")
                                    LeResult = Execute(OoAction)
                                End If
                            Next
                            OoAction.Action = GeAction.kkRemoveDiagramSelection
                        End If

                        'removing note links
                        If LeResult = GeActionResult.kkOk Then
                            For Each LoLink As DiagramLink In LoNoteLinksCollection
                                If LeResult = GeActionResult.kkOk AndAlso fcDiagram.Selection.Items.Contains(LoLink) Then
                                    OoAction.Action = GeAction.kkRemoveLinkFromDiagram
                                    OoAction.SetData(LoLink, "LINK")
                                    LeResult = Execute(OoAction)
                                End If
                            Next
                            OoAction.Action = GeAction.kkRemoveDiagramSelection
                        End If

                        'removing modules
                        If LeResult = GeActionResult.kkOk Then
                            For Each LoNode As DiagramNode In LoModulesCollection
                                If LeResult = GeActionResult.kkOk AndAlso fcDiagram.Selection.Items.Contains(LoNode) Then
                                    OoAction.Action = GeAction.kkRemoveModuleFromDiagram
                                    OoAction.SetData(LoNode, "NODE")
                                    LeResult = Execute(OoAction)
                                End If
                            Next
                            OoAction.Action = GeAction.kkRemoveDiagramSelection
                        End If

                        'removing UCD nodes
                        If LeResult = GeActionResult.kkOk Then
                            For Each LoDiagramNode As DiagramNode In LoUCDnodesCollection
                                fcDiagram.Nodes.Remove(LoDiagramNode)
                            Next
                            OoAction.Action = GeAction.kkRemoveDiagramSelection
                        End If
                    End If
                    '**************** removing in my own order (1. containers, 2. tables...) ****************
                Case GeAction.kkRemoveLinkFromDiagram
                    Dim LoMMLinkNode As ClsMMLinkNode = OoAction.GetData("LINK")
                    Select Case LoMMLinkNode.MMTypeOfLink
                        Case GeTypeOfLink.kkClassDiagramRelationship
                            Dim LoMMOriginTableNode As ClsMMTableNode = CType(LoMMLinkNode.Origin, ClsMMTableNode)
                            Dim LoMMDestinationTableNode As ClsMMTableNode = CType(LoMMLinkNode.Destination, ClsMMTableNode)
                            LeResult = AmodVersion.DeleteRelationShipFromHierarchy(LoMMOriginTableNode.AppTableName, LoMMDestinationTableNode.AppTableName)
                            If LeResult = GeActionResult.kkOk Then
                                Me.fcDiagram.Links.Remove(LoMMLinkNode)
                                'rebulid table coz FK was removed
                                LoMMDestinationTableNode.MMRebuildTable(AmodVersion.GetDataTableAllRowsSortedByPosition(LoMMDestinationTableNode.AppTableName))
                                'rerouting links of original and destination tables
                                '' ''LoMMOriginTableNode.MMRouteLinks()
                                '' ''LoMMDestinationTableNode.MMRouteLinks()
                            End If
                        Case GeTypeOfLink.kkUseCaseRelationship
                            Me.fcDiagram.Links.Remove(LoMMLinkNode)
                        Case GeTypeOfLink.kkNote
                            '' ''Dim LoMMOriginNode As DiagramNode = LoMMLinkNode.Origin
                            '' ''Dim LoMMDestinationNode As DiagramNode = LoMMLinkNode.Destination
                            Me.fcDiagram.Links.Remove(LoMMLinkNode)

                            'rerouting links of original and destination nodes
                            '' ''Select Case LoMMOriginNode.GetType.Name
                            '' ''    Case "ClsMMTableNode"
                            '' ''        Dim LoMMOriginTableNode As ClsMMTableNode = CType(LoMMOriginNode, ClsMMTableNode)
                            '' ''        LoMMOriginTableNode.MMRouteLinks()
                            '' ''    Case "ClsMMContainerNode"
                            '' ''        Dim LoMMOriginContainerNode As ClsMMContainerNode = CType(LoMMOriginNode, ClsMMContainerNode)
                            '' ''        LoMMOriginContainerNode.MMRouteLinks()
                            '' ''    Case "ClsMMNoteNode"
                            '' ''        Dim LoMMOriginNoteNode As ClsMMNoteNode = CType(LoMMOriginNode, ClsMMNoteNode)
                            '' ''        LoMMOriginNoteNode.MMRouteLinks()
                            '' ''End Select
                            '' ''Select Case LoMMLinkNode.Destination.GetType.Name
                            '' ''    Case "ClsMMTableNode"
                            '' ''        Dim LoMMDestinationTableNode As ClsMMTableNode = CType(LoMMDestinationNode, ClsMMTableNode)
                            '' ''        LoMMDestinationTableNode.MMRouteLinks()
                            '' ''    Case "ClsMMContainerNode"
                            '' ''        Dim LoMMDestinationContainerNode As ClsMMContainerNode = CType(LoMMDestinationNode, ClsMMContainerNode)
                            '' ''        LoMMDestinationContainerNode.MMRouteLinks()
                            '' ''    Case "ClsMMNoteNode"
                            '' ''        Dim LoMMDestinationNoteNode As ClsMMNoteNode = CType(LoMMDestinationNode, ClsMMNoteNode)
                            '' ''        LoMMDestinationNoteNode.MMRouteLinks()
                            '' ''End Select
                        Case Else
                            Debug.Print("CHYBA!!! - Execute - ACTION - kkRemoveLinkFromDiagram")
                    End Select
                Case GeAction.kkRemoveModuleFromDiagram
                    Dim LoMMModuleNode As ClsMMModuleNode = OoAction.GetData("NODE")

                    Select Case MessageBox.Show("Naozaj chcete odstranit modul """ & LoMMModuleNode.Text & """?" & vbNewLine & vbNewLine & "Vazby vsetkych poloziek tried, na ktore je tento modul napojeny budu zrusene! Subor modulu ani jeho ine vygenerovane subory nebudu odstranene. Modul mozete do projektu kedykolvek opat pridat, no vazby napojeneho modulu sa neobnovia!", "Odstranenie modulu", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)
                        Case DialogResult.Yes
                            Dim LsAmodFilePath As String = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.GetAmodFilePath(LoMMModuleNode.ModuleName)
                            Dim LoDSaModFile As ClsDSaModFile = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.OpenedAmodFiles.GetItem(LsAmodFilePath, True)

                            'close all opened verions and diagrams
                            If LoDSaModFile IsNot Nothing Then
                                OoAction.Action = GeAction.kkaModCloseAllVersionsOfAmodFile
                                OoAction.SetData(LoDSaModFile, "AMODFILE")
                                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                OoAction.Action = GeAction.kkRemoveModuleFromDiagram
                            End If

                            If LeResult = GeActionResult.kkOk Then
                                LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.DeleteModule(LoMMModuleNode.ModuleName)
                                If LeResult = GeActionResult.kkOk Then
                                    'rename joined module of child modules
                                    RenameJoinedModuleOfChildModules(LoMMModuleNode.ModuleName, "")
                                    'remove module from diagram
                                    MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.fcDiagram.Nodes.Remove(LoMMModuleNode)
                                    'since there was a change also in diagram I need to save also diagram, so I cant call only MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.DSaModSolutionFile.SaveFile(False)
                                    OoAction.Action = GeAction.kkaModSolutionSaveFile
                                    LeResult = MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.Execute(OoAction)
                                    OoAction.Action = GeAction.kkRemoveModuleFromDiagram

                                    'fills MoUcnComboboxJoinedModule in main tab with all modules from aMod solution
                                    MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.FillComboboxJoinedModule()
                                    'refreshing selected item of diagrams of all tabs
                                    RefreshSelectedItemsOfAllTabs()
                                End If
                            End If
                        Case DialogResult.No
                            LeResult = GeActionResult.kkCancel
                    End Select
                Case GeAction.kkRemoveNoteFromDiagram
                    Dim LoMMNoteNode As ClsMMNoteNode = OoAction.GetData("NODE")
                    Dim LoNoteLinksCollection As List(Of ClsMMLinkNode) = New List(Of ClsMMLinkNode)

                    'filling collections of links
                    For Each LoLink As DiagramLink In LoMMNoteNode.GetAllLinks
                        Dim LoMMLinkNode As ClsMMLinkNode = CType(LoLink, ClsMMLinkNode)
                        Select Case LoMMLinkNode.MMTypeOfLink
                            Case GeTypeOfLink.kkNote
                                LoNoteLinksCollection.Add(LoLink)
                            Case Else
                                Debug.Print("CHYBA!!! - Execute - ACTION - kkRemoveShapeNodeFromDiagram - GetAllLinks")
                        End Select
                    Next

                    'removing note links
                    If LeResult = GeActionResult.kkOk Then
                        For Each LoLink As DiagramLink In LoNoteLinksCollection
                            If LeResult = GeActionResult.kkOk Then
                                OoAction.Action = GeAction.kkRemoveLinkFromDiagram
                                OoAction.SetData(LoLink, "LINK")
                                LeResult = Execute(OoAction)
                            End If
                        Next
                        OoAction.Action = GeAction.kkRemoveNoteFromDiagram
                    End If

                    If LeResult = GeActionResult.kkOk Then
                        Select Case MoTabPage.TypeOfTab
                            Case GeTypeOfTab.kkClassDiagramTab
                                'remove note from DS
                                LeResult = AmodVersion.DeleteNote(LoMMNoteNode.ID)
                            Case Else
                                'do nothing
                        End Select

                        If LeResult = GeActionResult.kkOk Then
                            Me.fcDiagram.Nodes.Remove(LoMMNoteNode)
                        End If
                    End If

                Case GeAction.kkRemoveTableFromDiagram
                    Dim LoMMTableNode As ClsMMTableNode = OoAction.GetData("NODE")
                    Dim LoRelationshipLinksCollection As List(Of ClsMMLinkNode) = New List(Of ClsMMLinkNode)
                    Dim LoNoteLinksCollection As List(Of ClsMMLinkNode) = New List(Of ClsMMLinkNode)
                    Dim LoMMParentContainerNode As ClsMMContainerNode = ContainerNode.GetContainer(LoMMTableNode)

                    'show warning about at least one table in conatiner? dont show it if table is going to be removed coz also its parent container is going to be removed
                    Dim LbRemovingAlsoContainer As Boolean = OoAction.GetData("REMOVINGALSOCONTAINER")
                    If Not LbRemovingAlsoContainer And LoMMParentContainerNode.SubordinateGroup.AttachedNodes.Count = 1 Then
                        MessageBox.Show("Triedu nie je mozne odstranit, pretoze formular musi obsahovat aspon jednu triedu!", "Triedu nie je mozne odstranit", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                    Else
                        'filling collections of links
                        For Each LoLink As DiagramLink In LoMMTableNode.GetAllLinks
                            Dim LoMMLinkNode As ClsMMLinkNode = CType(LoLink, ClsMMLinkNode)
                            Select Case LoMMLinkNode.MMTypeOfLink
                                Case GeTypeOfLink.kkClassDiagramRelationship
                                    LoRelationshipLinksCollection.Add(LoLink)
                                Case GeTypeOfLink.kkNote
                                    LoNoteLinksCollection.Add(LoLink)
                                Case Else
                                    Debug.Print("CHYBA!!! - Execute - ACTION - kkRemoveTableFromDiagram - GetAllLinks")
                            End Select
                        Next

                        'removing relationship links
                        If LeResult = GeActionResult.kkOk Then
                            For Each LoLink As DiagramLink In LoRelationshipLinksCollection
                                If LeResult = GeActionResult.kkOk Then
                                    OoAction.Action = GeAction.kkRemoveLinkFromDiagram
                                    OoAction.SetData(LoLink, "LINK")
                                    LeResult = Execute(OoAction)
                                End If
                            Next
                            OoAction.Action = GeAction.kkRemoveTableFromDiagram
                        End If

                        'removing note links
                        If LeResult = GeActionResult.kkOk Then
                            For Each LoLink As DiagramLink In LoNoteLinksCollection
                                If LeResult = GeActionResult.kkOk Then
                                    OoAction.Action = GeAction.kkRemoveLinkFromDiagram
                                    OoAction.SetData(LoLink, "LINK")
                                    LeResult = Execute(OoAction)
                                End If
                            Next
                            OoAction.Action = GeAction.kkRemoveTableFromDiagram
                        End If

                        If LeResult = GeActionResult.kkOk Then
                            Dim LbIsAnyColumnJoinedToModule As Boolean = AmodVersion.GetIfTableHasColumnsJoinedToModule(LoMMTableNode.AppTableName)
                            LeResult = AmodVersion.DeleteDataTable(LoMMTableNode.AppTableName)
                            If LeResult = GeActionResult.kkOk Then
                                Me.fcDiagram.Nodes.Remove(LoMMTableNode)
                                LoMMParentContainerNode.MMResizeAllToFitContainer()

                                If LbIsAnyColumnJoinedToModule Then
                                    'if any column was joined to any module Im going to refresh joined links and other things in main tab so I need to save this change in aMod version
                                    OoAction.Action = GeAction.kkaModSaveVersionAndFile
                                    Execute(OoAction)
                                    OoAction.Action = GeAction.kkRemoveTableFromDiagram

                                    'refreshes joined modules links within main tab diagram
                                    MoMainTabPage.ucnDiagramCanvasAdvanced.ucnDiagramCanvasBaseUC.RefreshJoinedModulesLinksOfChildModule(DSaModFile.GetLastVersionModuleName)
                                End If

                                'refreshes panel in main tab with table columns info joined to module
                                If IsThisTheLastVersion Then RefreshTableColumnsJoinedToModule(DSaModFile.GetLastVersionModuleName, LoMMParentContainerNode.UnitName, LoMMTableNode.AppTableName, "")
                            End If
                        End If
                    End If
                Case GeAction.kkRemoveContainerFromDiagram
                    Dim LoMMContainerNode As ClsMMContainerNode = OoAction.GetData("NODE")
                    Dim LoNoteLinksCollection As List(Of ClsMMLinkNode) = New List(Of ClsMMLinkNode)
                    Dim LoTablesCollection As List(Of ClsMMTableNode) = New List(Of ClsMMTableNode)

                    'filling collections of links
                    For Each LoLink As DiagramLink In LoMMContainerNode.GetAllLinks
                        Dim LoMMLinkNode As ClsMMLinkNode = CType(LoLink, ClsMMLinkNode)
                        Select Case LoMMLinkNode.MMTypeOfLink
                            Case GeTypeOfLink.kkNote
                                LoNoteLinksCollection.Add(LoLink)
                            Case Else
                                Debug.Print("CHYBA!!! - Execute - ACTION - kkRemoveContainerFromDiagram - GetAllLinks")
                        End Select
                    Next
                    'filling collections of tables
                    If LoMMContainerNode.SubordinateGroup IsNot Nothing Then
                        For Each LoMMTableNode As ClsMMTableNode In LoMMContainerNode.SubordinateGroup.AttachedNodes
                            If LoMMTableNode.GetType.Name = "ClsMMTableNode" Then
                                LoTablesCollection.Add(LoMMTableNode)
                            Else
                                Debug.Print("CHYBA!!! - Execute - ACTION - kkRemoveContainerFromDiagram - If LoMMTableNode.GetType.Name = ClsMMTableNode")
                            End If
                        Next
                    End If

                    'removing all child tables
                    If LeResult = GeActionResult.kkOk Then
                        'flag, that container is going to be removed, so condition on at least one table in container is not checked while removing table
                        OoAction.SetData(True, "REMOVINGALSOCONTAINER")
                        For Each LoMMTableNode As ClsMMTableNode In LoTablesCollection
                            If LeResult = GeActionResult.kkOk Then
                                OoAction.Action = GeAction.kkRemoveTableFromDiagram
                                OoAction.SetData(LoMMTableNode, "NODE")
                                LeResult = Execute(OoAction)
                            End If
                        Next
                        OoAction.Action = GeAction.kkRemoveContainerFromDiagram
                    End If

                    'removing note links  
                    If LeResult = GeActionResult.kkOk Then
                        For Each LoLink As DiagramLink In LoNoteLinksCollection
                            If LeResult = GeActionResult.kkOk Then
                                OoAction.Action = GeAction.kkRemoveLinkFromDiagram
                                OoAction.SetData(LoLink, "LINK")
                                LeResult = Execute(OoAction)
                            End If
                        Next
                        OoAction.Action = GeAction.kkRemoveContainerFromDiagram
                    End If

                    If LeResult = GeActionResult.kkOk Then
                        LeResult = AmodVersion.DeleteUnit(LoMMContainerNode.UnitName)
                        If LeResult = GeActionResult.kkOk Then
                            Me.fcDiagram.Nodes.Remove(LoMMContainerNode)
                        End If
                    End If
                Case GeAction.kkLayoutDiagram
                    MoDiagramLayout.Arrange(fcDiagram, OoAction.GetData("LAYOUTENGINE"))
                Case GeAction.kkBuildDiagram
                    LeResult = BuildWholeDiagram()

                    If LeResult = GeActionResult.kkOk Then
                        OoAction.Action = GeAction.kkLayoutDiagram
                        OoAction.SetData(GeTypeOfLayout.kkTreeLayout, "LAYOUTENGINE")
                        LeResult = Execute(OoAction)
                        OoAction.Action = GeAction.kkBuildDiagram
                    End If
            End Select
            '---------------------------------------------
            'ACTION AFTER ACTION
            '---------------------------------------------
            Select Case OoAction.Action
                Case GeAction.kkInitTab, GeAction.kkaModSolutionOpenFile, GeAction.kkaModSolutionNewSolution, GeAction.kkaModSolutionCloseFile, GeAction.kkaModOpenVersion, GeAction.kkaModOpenUCDofModule
                    If LeResult = GeActionResult.kkOk Then
                        SetAfterChangeOfStateOfFile()
                        SetAfterInit()
                    Else
                        Debug.Print("Po neuspesnej akcii kkaModSolutionCloseFile - cast ACTION AFTER ACTION!")
                    End If
            End Select

            '---------------------------------------------
            Return LeResult
            '---------------------------------------------

        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    '#######################################

#Region "Execute_STARA"

    '' '' ''#######################################
    '' '' ''execute function - heart of application
    ' '' ''Public Function Execute(ByRef OoAction As ClsAction) As GeActionResult
    ' '' ''    Try
    ' '' ''        Dim LeResult As GeActionResult = GeActionResult.kkOk
    ' '' ''        '---------------------------------------------
    ' '' ''        'ACTION BEFORE ACTION
    ' '' ''        '---------------------------------------------


    ' '' ''        '---------------------------------------------
    ' '' ''        'ACTION
    ' '' ''        '---------------------------------------------
    ' '' ''        Select Case OoAction.Action



    ' '' ''            Case GeAction.kkAddTableToHierarchy
    ' '' ''                LeResult = MoDsAmodFile.InsertNewTableToHierarchy(OoAction.GetData("NAMEOFTABLEFORHIERARCHY"))
    ' '' '' 
    ' '' ''            Case GeAction.kkCreateTemplate
    ' '' ''                Try
    ' '' ''                    Dim LoMMTableNode As ClsMMTableNode
    ' '' ''                    LoMMTableNode = CType(fcDiagram.ActiveItem, ClsMMTableNode)
    ' '' ''                    If LoMMTableNode IsNot Nothing Then
    ' '' ''                        'checking duplicity
    ' '' ''                        '' DOCASNE ''
    ' '' ''                        '' ''If UcnNodesToolbarUC.GetTemplate(LoMMTableNode.Caption) Is Nothing Then
    ' '' ''                        '' ''    'node from form
    ' '' ''                        '' ''    fcDiagramView.CopyToClipboard(False, False)
    ' '' ''                        '' ''    'same node in toolbar
    ' '' ''                        '' ''    UcnNodesToolbarUC.DiagramView.PasteFromClipboard(0, 0, False)

    ' '' ''                        '' ''    'creating datatable for data from table _a_Columns as copy of rows
    ' '' ''                        '' ''    Dim LoDataTable As DataTable = New DataTable
    ' '' ''                        '' ''    LoDataTable = MoAmodFile.Dataset.Tables("_a_Columns").Clone 'creating schema
    ' '' ''                        '' ''    Dim LoDataRows() As DataRow = MoAmodFile.GetColumnsOfTable(LoMMTableNode.Caption, "Position ASC")
    ' '' ''                        '' ''    For Each LoDataRow As DataRow In LoDataRows
    ' '' ''                        '' ''        Dim LoNewRow As DataRow = LoDataTable.NewRow
    ' '' ''                        '' ''        LoNewRow.ItemArray = LoDataRow.ItemArray
    ' '' ''                        '' ''        LoDataTable.Rows.Add(LoNewRow)
    ' '' ''                        '' ''    Next
    ' '' ''                        '' ''    'setting of tag
    ' '' ''                        '' ''    UcnNodesToolbarUC.GetTemplate(LoMMTableNode.Caption).Tag = LoDataTable
    ' '' ''                        '' ''    'saving
    ' '' ''                        '' ''    UcnNodesToolbarUC.SaveToolbar()
    ' '' ''                        '' ''    UcnNodesToolbarUC.RefreshToolbar()
    ' '' ''                        '' ''    LeResult = GeActionResult.kkOk
    ' '' ''                        '' ''Else
    ' '' ''                        '' ''    Debug.Print("CHYBA!!! - Execute - ACTION - kkCreateTemplate - GetTemplate")
    ' '' ''                        '' ''    LeResult = GeActionResult.kkError
    ' '' ''                        '' ''End If
    ' '' ''                    Else
    ' '' ''                        Debug.Print("CHYBA!!! - Execute - ACTION - kkCreateTemplate - LoMMTableNode Is Nothing")
    ' '' ''                        LeResult = GeActionResult.kkError
    ' '' ''                    End If
    ' '' ''                Catch ex As Exception
    ' '' ''                    LeResult = GeActionResult.kkError
    ' '' ''                End Try
    ' '' ''        End Select
    ' '' ''        '---------------------------------------------
    ' '' ''        'ACTION AFTER ACTION
    ' '' ''        '---------------------------------------------
    ' '' ''        Select Case OoAction.Action
    ' '' ''            Case GeAction.kkNewFile, GeAction.kkOpenFile, GeAction.kkCloseFile
    ' '' ''                If LeResult = GeActionResult.kkOk Then SetEnableAfterChangeOfStateOfFile()
    ' '' ''            Case GeAction.kkSaveFile
    ' '' ''                If LeResult = GeActionResult.kkOk Then
    ' '' ''                    SetCaptionOfForm()
    ' '' ''                    SetEnableMenu()
    ' '' ''                End If
    ' '' ''        End Select


    ' '' ''        '---------------------------------------------
    ' '' ''        Return LeResult
    ' '' ''        '---------------------------------------------

    ' '' ''    Catch ex As Exception
    ' '' ''        LogEventFromException(ex, , , )
    ' '' ''        Return GeActionResult.kkError
    ' '' ''    End Try
    ' '' ''End Function
    '' '' ''#######################################
#End Region

End Class